Variable names for controls on forms ?

S

SheldonMopes

I have a form which contains 32 text boxes. Each needs to be updated
when the forms opens.


Method 1:

..
..
..
rst1.MoveNext
txtBox1 = DLookup("[nLink]" "tblNames","[strSystem] = " & rst1!field1)
rst1.MoveNext
txtBox2 = DLookup("[nLink]" "tblNames","[strSystem] = " & rst1!field1)
rst1.Movenext
etc..
..
..
For all 32 text boxes.

I would prefer:

do while nCounter <=32
txtBox% = DLookup("[nLink]" "tblNames","strSystem = " & rst1!field1)
rst1.MoveNext
nCounter = nCounter+1
Loop

% being the number assigned to nCounter

Am I missing something obvious ?
Thanks in advance for any help
 
M

Marshall Barton

I have a form which contains 32 text boxes. Each needs to be updated
when the forms opens.

Method 1:
.
rst1.MoveNext
txtBox1 = DLookup("[nLink]" "tblNames","[strSystem] = " & rst1!field1)
rst1.MoveNext
txtBox2 = DLookup("[nLink]" "tblNames","[strSystem] = " & rst1!field1)
rst1.Movenext
etc..
For all 32 text boxes.

I would prefer:

do while nCounter <=32
txtBox% = DLookup("[nLink]" "tblNames","strSystem = " & rst1!field1)
rst1.MoveNext
nCounter = nCounter+1
Loop

% being the number assigned to nCounter


For k = 1 to 32
Me("txtBox" & k) = DLookup( . . .
rst1.MoveNext
Next k

But there had got to be a better way than doing all those
DLookups. It looks like you could just Join tblNames in
your recordset's query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top