Re: Handling single quotes " ' " in data
From: Douglas J. Steele (NOSPAM_djsteele_at_NOSPAM_canada.com)
Date: 01/14/05
- Next message: Douglas J. Steele: "Re: Dim db As DATABASE"
- Previous message: FBxiii: "RE: Dim db As DATABASE"
- In reply to: Irwin Williams: "Handling single quotes " ' " in data"
- Next in thread: Irwin Williams: "Re: Handling single quotes " ' " in data"
- Reply: Irwin Williams: "Re: Handling single quotes " ' " in data"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 14 Jan 2005 10:22:57 -0500
There's no reason not to store the single quotes.
Presumably your SQL statement is something like
strSQL = "INSERT INTO MyTable (MyField) " & _
"VALUES ( ' " & strFilename & " ' )"
(extra spaces added for clarity)
Try either:
strSQL = "INSERT INTO MyTable (MyField) " & _
"VALUES ( " & Chr$(34) & strFilename & Chr$(34) & " )"
or
strSQL = "INSERT INTO MyTable (MyField) " & _
"VALUES ( ' " & Replace(strFilename, " ' ", " ' ' ") & " ' )"
(remove the extra spaces in the parameters in the Replace statement before
running!)
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (No private e-mails, please) "Irwin Williams" <icon4irwin@hotmail.com> wrote in message news:OevELPk#EHA.2608@TK2MSFTNGP10.phx.gbl... > Hi, > I have been storing file locations in a table in access. The actual > location comes from a file object. > Sometimes a file name may have a single quote in it - and this is causing an > error in access. As such, i've been using the pipe character for internal > purposes - replacing the " ' " with " | ". And vice-versa when reporting > the information to users. > Does anyone know a better way of handling this? > > /irwin > >
- Next message: Douglas J. Steele: "Re: Dim db As DATABASE"
- Previous message: FBxiii: "RE: Dim db As DATABASE"
- In reply to: Irwin Williams: "Handling single quotes " ' " in data"
- Next in thread: Irwin Williams: "Re: Handling single quotes " ' " in data"
- Reply: Irwin Williams: "Re: Handling single quotes " ' " in data"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|