SQL in Control Source?

D

Dale Lundgren

Hi All-

I have a TextBox control that I need to populate from a Table different than
the default Table for the Form. Is it possible to use an SQL statement in
the "Control Source" field? I have not had any success so far.

Any help would be GREATLY appreciated!

Thanks,

Dale Lundgren
 
G

Gary Miller

Dale,

No, you can't do that directly. What you can do is populate it through VBA
in the OnCurrent event of the form. If it is only one item you are
populating I would suggest just using DLookup although you could open a
recordset with your SQL and do the same thing.

Dim strVar as String

strVar = DLookup("FieldYouWant","TableItsIn","Your WHERE clause from the SQL
here")
Me!ControlToPopulate = strVar

Gary Miller
 

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