Using a variable in a select statement

  • Thread starter Thread starter Pat Turner
  • Start date Start date
P

Pat Turner

I am trying to do pass a variable to a select statement.
A variable which I would declare in a dim statement

Select * from table WHERE field1 = (variable)
 
If the variable is a number, then the format is
"Select * from table WHERE field1 = " & (variable)
If it is a string, the format is
"Select * from table WHERE field1 = '" & (variable) & "'"
If it is a date, the format is
"Select * from table WHERE field1 = #" & format((variable),
"mm/dd/yyyy") & "#"

Hope This Helps
Gerald Stanley MCSD
 
Back
Top