the DoCmd.RunSQL method

  • Thread starter Thread starter Laurel
  • Start date Start date
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.
 
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 & """")
 
Back
Top