the DoCmd.RunSQL method

L

Laurel

How can I get at the results of a select statement? The
HELP just shows how to execute a SQL update command. I
want to find out the value of a column.... e.g., my SQL
command is as follows (colons are the syntax I would have
used in PowerBuilder embedded SQL.)

DoCmd.RunSQL "Select Period_Code into :strTempCode From
Periods where sort_order = :str_sort_Order"

fncPeriod_CodeinOrder = strTempCode

This, of course, doesn't work in VB. How would I do
this? Note - I'm not particularly experienced with SQL,
so please make responses detailed.
 
J

John Nurick

Hi Laurel,

Use something like this. Note the doubled quotes to get quote marks
round the string variable str_Sort_Order.

strTempCode = DLookup("Period_Code", "Periods", _
"Sort_Order = """ & str_Sort_Order & """")
 

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