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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to define variable witin SQL statement 1

Status
Not open for further replies.

DanKay1

Programmer
Jun 9, 2004
54
US
CurrentDb.OpenRecordset("SELECT CompanyList.CompanyCode, CompanyList.REINSURER FROM CompanyList Where Reinsurer = '" & cmbReinsurerName & "'")

cmbReinsurerName = "Loyd's"

and it Kicks me out is there a way to define the variable within sql statement so it would give an error.
it works for all other inputs except for ' - single quatation mark.

Thank you.
 
If ac2k or above, replace this:
Where Reinsurer = '" & cmbReinsurerName & "'")
By this:
Where Reinsurer = '" & Replace(cmbReinsurerName, "'", "''") & "'")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top