execute string as vb statement

  • Thread starter Thread starter Guest
  • Start date Start date
Robert said:
Is it possible to execute a string variable as a VB statement?


No.

But, if you'll explain more about what you're trying to do,
maybe someone can come up with an alternative approach.
 
I am trying to set the record source of a subform on a form but the same
needs to run for two different forms. I was hopeing to pass the form name
and concatenate it to the string and execute the string. I.E.
"Forms!" & formname & "!subformname.form.recordsource=select x from tablex"
 
Robert said:
I am trying to set the record source of a subform on a form but the
same needs to run for two different forms. I was hopeing to pass the
form name and concatenate it to the string and execute the string.
I.E. "Forms!" & formname & "!subformname.form.recordsource=select x
from tablex"

If it's just the form name you want to get from a variable, you're in
luck. This works:

Dim strFormName As String

strFormName = "frmFoo"

Forms(strFormName)!YourSubformName.Form.RecordSource = _
"SELECT X FROM TableX"
 
Thank you this did work very well.

Dirk Goldgar said:
If it's just the form name you want to get from a variable, you're in
luck. This works:

Dim strFormName As String

strFormName = "frmFoo"

Forms(strFormName)!YourSubformName.Form.RecordSource = _
"SELECT X FROM TableX"

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top