Use code to select textbox

  • Thread starter Thread starter aworkingman
  • Start date Start date
A

aworkingman

Guest
I have two forms; one is named “select” and has 9 check boxes
(arranged in a column, the top box is “check1”, the last is “check9”)
and the other is named “data” and has 9 textboxes (arranged in a
column, the top box is “text1”, the last is “text9”.
The user can check any box on the “select” form and then clicks
a command button opening up the “data” form.

I would like to use an “if” statement to determine if forms![select]![check#]
(# from 1 to 9) was checked, and then put some value into forms![data]![text#] (# from 1 to 9).

This is what I have so far, but don’t know how to correctly reference the checkbox or the textbox on either of the forms “select” or “data”:

Dim basecheck as String
Dim basetext as String
Dim x as Integer

For x = 1 To 9 Step 1

basecheck = “check” & x
basetext = “text” & x

If forms![select]![basecheck] = true then ‘ <<<<Having trouble here
Forms![data]![basetext] = “check box 1 was checked” ‘ <<<<Having trouble here
End If

Next x

Thanks for your help
 
You should reference the form controls using (" ") notation rather than ! notation in this case. Try this:
Code:
If Forms("select")(basecheck) = true then
    Forms("data")(basetext) = “check box 1 was checked”
End If
 
I'd be kinda suprised if the poster didn't also have to perform some type of string conversion function for the concatenation used for the textbox name...

basecheck = “check” & Format(x)
basetext = “text” & Format(x)

Doug.
 
dcx693 said:
You should reference the form controls using (" ") notation rather than ! notation in this case. Try this:
Code:
If Forms("select")(basecheck) = true then
    Forms("data")(basetext) = “check box 1 was checked”
End If

That worked fine, Thanks!
 

Users who are viewing this thread

Back
Top Bottom