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
 
Top