apostrophe in people's names

G

Guest

I looked at some of the previous messages involving apostrophes but I still
can't get my search to work. Here is the basic chunk of code:

Criteria = "[ReverseFullName] = '" & AddName & "'"
SignLinkTB.MoveFirst
SignLinkTB.Find Criteria

It is supposed to find ReverseFullName in the Signlink table.
AddName in a variable:

AddName = Forms![SignerForm]![SignerSelectCombo]

It all works perfect unless the employee has an apostrophe in their name
(O'Connor). I know I need more quotes in my Criteria line, the combinations I
tried don't work.
 
B

Bill Edwards

one option would be
Dim strQuote as string
strQuote = chr(34)

Criteria = "[ReverseFullName]=" & strQuote & AddName & strQuote
 
G

Guest

Bill,

That did not work for names with (or without) apostrophe.

Either way I get Run-Time error '3001'
Arguments are wrong type, are out of acceptable range, or are in conflict
with one another.

And the foolowing line is highlighted.

SignLinkTB.Find Criteria



Bill Edwards said:
one option would be
Dim strQuote as string
strQuote = chr(34)

Criteria = "[ReverseFullName]=" & strQuote & AddName & strQuote

Glen said:
I looked at some of the previous messages involving apostrophes but I still
can't get my search to work. Here is the basic chunk of code:

Criteria = "[ReverseFullName] = '" & AddName & "'"
SignLinkTB.MoveFirst
SignLinkTB.Find Criteria

It is supposed to find ReverseFullName in the Signlink table.
AddName in a variable:

AddName = Forms![SignerForm]![SignerSelectCombo]

It all works perfect unless the employee has an apostrophe in their name
(O'Connor). I know I need more quotes in my Criteria line, the
combinations I
tried don't work.
 
A

Allen Browne

Bill's solution goes give a correctly formatted search string, assuming that
ReverseFullName is a Text type field.

If your Find worked before but not now, there is something else wrong.

We have no information about what SignLinkTB is. If it is a DAO recordset,
you could try FindFirst instead of Find. But, of course that does not
explain why it would have worked before.

For another explanation of how to set up these quote delimiters, see:
Quotation marks within quotes
at:
http://allenbrowne.com/casu-17.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Glen said:
Bill,

That did not work for names with (or without) apostrophe.

Either way I get Run-Time error '3001'
Arguments are wrong type, are out of acceptable range, or are in conflict
with one another.

And the foolowing line is highlighted.

SignLinkTB.Find Criteria



Bill Edwards said:
one option would be
Dim strQuote as string
strQuote = chr(34)

Criteria = "[ReverseFullName]=" & strQuote & AddName & strQuote

Glen said:
I looked at some of the previous messages involving apostrophes but I
still
can't get my search to work. Here is the basic chunk of code:

Criteria = "[ReverseFullName] = '" & AddName & "'"
SignLinkTB.MoveFirst
SignLinkTB.Find Criteria

It is supposed to find ReverseFullName in the Signlink table.
AddName in a variable:

AddName = Forms![SignerForm]![SignerSelectCombo]

It all works perfect unless the employee has an apostrophe in their
name
(O'Connor). I know I need more quotes in my Criteria line, the
combinations I
tried don't work.
 
G

Guest

Thanks for your reply.

ReverseFullName is a text field in a table called Signlink

SignlinkTB is a ADO recordset based on:
Dim SignLinkTB As New ADODB.Recordset

SignLinkTB.Open "Signlink", myDB, adOpenKeyset, adLockOptimistic,
adCmdTableDirect

And yes, my code worked fine for names without apostrophe

Allen Browne said:
Bill's solution goes give a correctly formatted search string, assuming that
ReverseFullName is a Text type field.

If your Find worked before but not now, there is something else wrong.

We have no information about what SignLinkTB is. If it is a DAO recordset,
you could try FindFirst instead of Find. But, of course that does not
explain why it would have worked before.

For another explanation of how to set up these quote delimiters, see:
Quotation marks within quotes
at:
http://allenbrowne.com/casu-17.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Glen said:
Bill,

That did not work for names with (or without) apostrophe.

Either way I get Run-Time error '3001'
Arguments are wrong type, are out of acceptable range, or are in conflict
with one another.

And the foolowing line is highlighted.

SignLinkTB.Find Criteria



Bill Edwards said:
one option would be
Dim strQuote as string
strQuote = chr(34)

Criteria = "[ReverseFullName]=" & strQuote & AddName & strQuote

I looked at some of the previous messages involving apostrophes but I
still
can't get my search to work. Here is the basic chunk of code:

Criteria = "[ReverseFullName] = '" & AddName & "'"
SignLinkTB.MoveFirst
SignLinkTB.Find Criteria

It is supposed to find ReverseFullName in the Signlink table.
AddName in a variable:

AddName = Forms![SignerForm]![SignerSelectCombo]

It all works perfect unless the employee has an apostrophe in their
name
(O'Connor). I know I need more quotes in my Criteria line, the
combinations I
tried don't work.
 

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