bulding control names on the fly

  • Thread starter Thread starter Santiago Gomez
  • Start date Start date
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.
 
Perhaps

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

Pavel
 
Back
Top