Apostrophe in query, probably an easy one but urgent...

  • Thread starter Thread starter JustinP
  • Start date Start date
J

JustinP

I'm created a query from whatever the user passes through textboxes.

Sometimes these have apostrophes... As an example, O'KEEFE is entered
into the textbox...

This is part of the code
strSQL = Update ...(omited)... MasterTable.OWNER1_SURNAME = '" &
Replace(txtOWNER1_SURNAME, "'", "' & '")

Evaluates to:
MasterTable.OWNER1_SURNAME = 'O' & 'KEEFE'

How can I handle these apostrophes and account for null text boxes if
they exist?
 
I've also tried using:

IIf(txtOWNER1_SURNAME Is Not Null, (Replace(txtOWNER1_SURNAME, "'",
"''")), "")
 
I sorted it...

Just use:

& Chr$(34) & txtOWNER1_SURNAME &Chr$(34)

Then puts double qoutes around txtOWNER1_SURNAME (e.g. "O'BRIAN")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top