
I'm having a problem with a 'special' character in a query
You do need to delimit names that contain blanks or special characters with
brackets, but that's not your original problem. You're trying to build a
predicate with a string literal, and the variable you're embedding in the
literal contains quotes. My or Sandra Daigle's solution should do the
trick. You basically want to change:
WHERE Customer.Dealer = 'John's used cars'
To (my solution):
WHERE Customer.Dealer = 'John''s used cars'
Or (Sandra's solution):
WHERE Customer.Dealer = "John's used cars"
--
John Viescas, author
"Microsoft Office Access 2003 Inside Out" (coming soon)
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
Quote:
> Someone had suggested using ']'
> "SELECT '[ quote $val ]' AS ret"
> Has anyone tried this?
> Scott
> > strSQL = strSQL & " WHERE customer.dealer='" &
Replace(me!incident_number,
Quote:
> > "'", "''") & "';"
> > --
> > John Viescas, author
> > "Microsoft Office Access 2003 Inside Out" (coming soon)
> > "Running Microsoft Access 2000"
> > "SQL Queries for Mere Mortals"
> > http://www.viescas.com/
> > (Microsoft Access MVP since 1993)
> > > Set dbs = CurrentDb()
> > > strSQL = "SELECT * FROM customer"
> > > strSQL = strSQL & " WHERE customer.dealer='"& me!incident_number &
> > "';"
> > > Set rst = dbs.OpenRecordset(strSQL)
> > > My problem is that the variable 'incident_number' is system
> generated
> > > from another application and within the string type variable are ASCII
> > text
> > > characters that are causing my query to crash.
> > > The character is a ' (single quote). Now within the code above
the
> > > query has to have a single quote to distinquish a text variable from
the
> > > remaining query.
> > > How can I get around is this issue?
> > > Scott