bulding control names on the fly

S

Santiago Gomez

I want to use the same procedure for different controls on a form. depending
on which control the user changes, a different table is updated.

How can I construct the control name on they fly, before accessing the value
inside of it?

' set the table name based on passed parameter from form
strTable = "tbl" & strBusName
'I need to get at the value of the Me.txtDiversity & strBusName & .Value
(which is a Double number)
ctlName = "Me.txtDiversity" & strBusName & ".Value"

Set rst = New ADODB.Recordset
rst.Open strTable, CurrentProject.Connection, adOpenKeyset,
adLockOptimistic


With rst
.MoveFirst
Do Until .EOF
.Fields("Courses") = ctlName 'this is where I need the
value from the text box
.Update
.MoveNext
Loop


thanks a lot.
 
P

Pavel Romashkin

Perhaps

With rst
.MoveFirst
Do Until .EOF
.Fields("Courses") = Me.Form.Controls(strBusName).Value
.Update
.MoveNext
Loop
end with

Pavel
 

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