A company name such as Cathy's Crawly Composters contains an isolated single-quote character.
I have experimented with removing all single-quotes from a company name to generate a satisfactory key, but then I have to remove all single quotes from all company names whenever I want to lookup the table using CompanyName as a key.
Code: Select all
strClientBusiness = rstCLIENT.Fields("Business")
strClientBusiness = strReplaceAll(strClientBusiness, "'", "")
Set rstCOMPANY = dbs.OpenRecordset("select * from Company where Business = '" & strClientBusiness & "'")
The business name might contain any character nowadays. Gone are the days when only a single-quote (O'Leary, O'Clogs etc.) marred the pristine letters-only format.
This means that either one strips all non-alpha characters on the fly for every type of query, or else one has to be very crafty in crating a WHERE cluse.
Right?
In the case of single-quotes it seems to me that I would end up:
(1) Replacing all single-quotes with doubled single-quotes
(2) Wrapping all of that in doubled double-quotes to be able to embed the lot in a VBA character string.
Or have I missed something here?