accessing apostrophe record in ms access using ms word vba

C

cmpq

Hi
I'm having trouble accessing a record in access as a string from a word macro.

The record is a list of surnames and 1 of the surnames contains an
apostrophe e.g. O'Sullivan.

heres my code
Set rs = gdbLdsData.OpenRecordset("Select * from qslUsers Where Name = '" &
StrSection & "'", dbOpenSnapshot)
txtUserText = rs("FirstName") & " " & rs("Surname") + vbCr & rs("Title")

doing something simple as this does not display
temp As String
msgBox (rs("Surname"))

I can't make any changes to Access as there are other word macros that rely
on this. Is there any way around this?

Thanks in advance
 
T

Tony Jollans

Could you rephrase the question? I can't see a problem in what you've
posted.
 
C

cmpq

when i retrieve a surname with an apostrophe from access it doesn't show up...

as in when i do

msgBox(rs("Surname"))

the msgbox comes up as an string empty

any ideas?
 
C

cmpq

when i retrieve a surname with an apostrophe from access it doesn't show up...

as in when i do

msgBox(rs("Surname"))

the msgbox comes up as an string empty

any ideas?
 
T

Tony Jollans

I would need to know more of what you are doing and how [Name] relates to
Surname but I suspect that the SQL is not properly formed. It *might* work
better if you tried:

... Where Name = """ & StrSection & """", ...
 
C

cmpq

YES that works!@

thank you very much =)

from this ".....Where Name = ' " & StrSection & " ' "
to ".....Where Name = " "" & StrSection & """ "



Tony Jollans said:
I would need to know more of what you are doing and how [Name] relates to
Surname but I suspect that the SQL is not properly formed. It *might* work
better if you tried:

... Where Name = " " " & StrSection & " """, ...

--
Enjoy,
Tony

cmpq said:
when i retrieve a surname with an apostrophe from access it doesn't show
up...

as in when i do

msgBox(rs("Surname"))

the msgbox comes up as an string empty

any ideas?
 
C

cmpq

YES that works!@

thank you very much =)

from this ".....Where Name = ' " & StrSection & " ' "
to ".....Where Name = " "" & StrSection & """ "



Tony Jollans said:
I would need to know more of what you are doing and how [Name] relates to
Surname but I suspect that the SQL is not properly formed. It *might* work
better if you tried:

... Where Name = " " " & StrSection & " """, ...

--
Enjoy,
Tony

cmpq said:
when i retrieve a surname with an apostrophe from access it doesn't show
up...

as in when i do

msgBox(rs("Surname"))

the msgbox comes up as an string empty

any ideas?
 
C

cmpq

thank you that does work

Tony Jollans said:
I would need to know more of what you are doing and how [Name] relates to
Surname but I suspect that the SQL is not properly formed. It *might* work
better if you tried:

... Where Name = """ & StrSection & """", ...

--
Enjoy,
Tony

cmpq said:
when i retrieve a surname with an apostrophe from access it doesn't show
up...

as in when i do

msgBox(rs("Surname"))

the msgbox comes up as an string empty

any ideas?
 

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

Top