Use SQL in VBA to populate a text box on a form (1 Viewer)

Keith Nichols

Registered User.
Local time
Today, 03:58
Joined
Jan 27, 2006
Messages
431
I know how to do this with a combo box. After defining the SQLtext and WClause something like:

with me.cbocombobox
____.rowsource = SQLtext & Wclause
____.requery
end with

How do I (can I?) use the SQL in VBA to populate a text box in a similar manner? I have tried various versions of me.textbox = sqltext & Wclause etc, but to no avail.

Cheers.
 

SamDeMan

Registered User.
Local time
Yesterday, 20:58
Joined
Aug 22, 2005
Messages
182
you are trying to get the result of the SQL statement in your Textbox? if so, you need to execute (run) the SQL statement before you asign it to the textbox. Try something like dLookup or maybe docmd.runSQL (i don't think this later one will work for you).

sam
 

Keith Nichols

Registered User.
Local time
Today, 03:58
Joined
Jan 27, 2006
Messages
431
Thanks for the response Sam.

I tried various versions of defining variables and trying to make them = sqltext so that I could then set the text box to that value but couldn't get the hang of it. I'm guessing this can be done and will be simple, I just can't figure it.

Regards,
 

Users who are viewing this thread

Top Bottom