Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

evaluating code that is held in a string

Status
Not open for further replies.

MarkGreen

Technical User
Oct 4, 2002
40
GB
Hi,
Is there any way of, having looked up a String value from a table, evaluting it in visual basic. It seems the eval function isnt sufficient to eval commands such as

"forms!form1!control1 = 2"

Any help is greatly appreciated!!
Mark
 
It's tricky, but you could loop thru all of the controls on the form, find the one you want by name (you would have to parse the string to extract the name). Then by setting an object you should be able to update the text/value property.

An alternative would be to set up a case structure so that you can select the appropriate case by the name of the control (parsing is still up to you) and set the property within the case. Something like
Code:
  nValue = 2
  Select Case sControlName
    Case "control1"
      forms!form1!control1.Value = nValue
  End Select
Kind of depends on how many controls you're working with.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top