Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL and Variables

Status
Not open for further replies.

lizray

Programmer
Joined
May 14, 2008
Messages
126
Location
AU
I am construction a query and want to include a field as an expression as follows:
IIF(isnull(Place),strPlacename,Place)
where place is a field in a table; but strPlacename is a variable containing the name of a place to be used if Place is Null. SQL has a problem with it. I have tried "'" & strPlacename & "'" but no luck... How can I get this to work ??
 
Do you create the SQL by code ?
Code:
strSQL = strSQL & ", Nz(Place,'" & strPlacename & "')"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PH. I havent heard of the Nz function, but tried it and the string " & strPlacename & " appeared in that field, rather then the actual variable stored in strPlacename. I started with Design view in access query and then have been working from the SQL view
 
SQL can't retrieve variables but functions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top