execute string as vb statement

M

Marshall Barton

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.
 
G

Guest

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"
 
D

Dirk Goldgar

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"
 
G

Guest

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)
 

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