By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,647 Members | 1,444 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,647 IT Pros & Developers. It's quick & easy.

Combo Box error with apostrophe

P: n/a
Today's problem is - my combo box works great until it comes across a name
with an apostrophe, such as Bill's Bike Shop. I'm sure this is very common
problem and I'm sure the work around is very simple. But danged if I can
find it. Thanks for your help.
Becky
Nov 15 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a

Rebecca Smith wrote:
Today's problem is - my combo box works great until it comes across a name
with an apostrophe, such as Bill's Bike Shop. I'm sure this is very common
problem and I'm sure the work around is very simple. But danged if I can
find it. Thanks for your help.
Becky
What exactly is the problem?

Bruce

Nov 15 '06 #2

P: n/a
On Wed, 15 Nov 2006 10:09:40 -0800, Rebecca Smith wrote:
Today's problem is - my combo box works great until it comes across a name
with an apostrophe, such as Bill's Bike Shop. I'm sure this is very common
problem and I'm sure the work around is very simple. But danged if I can
find it. Thanks for your help.
Becky
Rebecca,
It's easier to 'fix' if you post your exact combo box RowSource SQL.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Nov 15 '06 #3

P: n/a
The Row Source is tblCommercialMembers and event is:

Private Sub cboCompanyName_AfterUpdate()
' Find the record that matches the control.
With Me
.RecordsetClone.FindFirst "[CompanyName] = '" & Me![cboCompanyName]
& "'"
.Bookmark = Me.RecordsetClone.Bookmark
End With

Thank,
R.
"fredg" <fg******@example.invalidwrote in message
news:14******************************@40tude.net.. .
On Wed, 15 Nov 2006 10:09:40 -0800, Rebecca Smith wrote:
>Today's problem is - my combo box works great until it comes across a
name
with an apostrophe, such as Bill's Bike Shop. I'm sure this is very
common
problem and I'm sure the work around is very simple. But danged if I can
find it. Thanks for your help.
Becky

Rebecca,
It's easier to 'fix' if you post your exact combo box RowSource SQL.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Nov 15 '06 #4

P: n/a
On Wed, 15 Nov 2006 10:43:13 -0800, "Rebecca Smith"
<re************@comcast.netwrote:

The apostrophe is a string terminator. So it would try to FindFirst
CompanyName = 'Bill'
You have to double up on those characters, for example with the
Replace function:
..RecordsetClone.FindFirst "[CompanyName] = '" &
Replace(Me![cboCompanyName],"'", "''")
& "'"

-Tom.

>The Row Source is tblCommercialMembers and event is:

Private Sub cboCompanyName_AfterUpdate()
' Find the record that matches the control.
With Me
.RecordsetClone.FindFirst "[CompanyName] = '" & Me![cboCompanyName]
& "'"
.Bookmark = Me.RecordsetClone.Bookmark
End With

Thank,
R.
"fredg" <fg******@example.invalidwrote in message
news:14******************************@40tude.net. ..
>On Wed, 15 Nov 2006 10:09:40 -0800, Rebecca Smith wrote:
>>Today's problem is - my combo box works great until it comes across a
name
with an apostrophe, such as Bill's Bike Shop. I'm sure this is very
common
problem and I'm sure the work around is very simple. But danged if I can
find it. Thanks for your help.
Becky

Rebecca,
It's easier to 'fix' if you post your exact combo box RowSource SQL.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Nov 15 '06 #5

P: n/a
On Wed, 15 Nov 2006 11:54:12 -0700, Tom van Stiphout
<no*************@cox.netwrote:

Better still:
Make your combobox a 2-column dropdown, with a hidden CustomerID, and
then search by that number.

-Tom.

>On Wed, 15 Nov 2006 10:43:13 -0800, "Rebecca Smith"
<re************@comcast.netwrote:

The apostrophe is a string terminator. So it would try to FindFirst
CompanyName = 'Bill'
You have to double up on those characters, for example with the
Replace function:
.RecordsetClone.FindFirst "[CompanyName] = '" &
Replace(Me![cboCompanyName],"'", "''")
& "'"

-Tom.

>>The Row Source is tblCommercialMembers and event is:

Private Sub cboCompanyName_AfterUpdate()
' Find the record that matches the control.
With Me
.RecordsetClone.FindFirst "[CompanyName] = '" & Me![cboCompanyName]
& "'"
.Bookmark = Me.RecordsetClone.Bookmark
End With

Thank,
R.
"fredg" <fg******@example.invalidwrote in message
news:14******************************@40tude.net ...
>>On Wed, 15 Nov 2006 10:09:40 -0800, Rebecca Smith wrote:

Today's problem is - my combo box works great until it comes across a
name
with an apostrophe, such as Bill's Bike Shop. I'm sure this is very
common
problem and I'm sure the work around is very simple. But danged if I can
find it. Thanks for your help.
Becky

Rebecca,
It's easier to 'fix' if you post your exact combo box RowSource SQL.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Nov 15 '06 #6

P: n/a
Works exquisitely - thanks tons!
B.

"Tom van Stiphout" <no*************@cox.netwrote in message
news:pe********************************@4ax.com...
On Wed, 15 Nov 2006 10:43:13 -0800, "Rebecca Smith"
<re************@comcast.netwrote:

The apostrophe is a string terminator. So it would try to FindFirst
CompanyName = 'Bill'
You have to double up on those characters, for example with the
Replace function:
.RecordsetClone.FindFirst "[CompanyName] = '" &
Replace(Me![cboCompanyName],"'", "''")
& "'"

-Tom.

>>The Row Source is tblCommercialMembers and event is:

Private Sub cboCompanyName_AfterUpdate()
' Find the record that matches the control.
With Me
.RecordsetClone.FindFirst "[CompanyName] = '" &
Me![cboCompanyName]
& "'"
.Bookmark = Me.RecordsetClone.Bookmark
End With

Nov 15 '06 #7

P: n/a
On Wed, 15 Nov 2006 10:43:13 -0800, Rebecca Smith wrote:
The Row Source is tblCommercialMembers and event is:

Private Sub cboCompanyName_AfterUpdate()
' Find the record that matches the control.
With Me
.RecordsetClone.FindFirst "[CompanyName] = '" & Me![cboCompanyName]
& "'"
.Bookmark = Me.RecordsetClone.Bookmark
End With

Thank,
R.

"fredg" <fg******@example.invalidwrote in message
news:14******************************@40tude.net.. .
>On Wed, 15 Nov 2006 10:09:40 -0800, Rebecca Smith wrote:
>>Today's problem is - my combo box works great until it comes across a
name
with an apostrophe, such as Bill's Bike Shop. I'm sure this is very
common
problem and I'm sure the work around is very simple. But danged if I can
find it. Thanks for your help.
Becky

Rebecca,
It's easier to 'fix' if you post your exact combo box RowSource SQL.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
In addition to Tom's comments, this too will work:

Me.RecordsetClone.FindFirst "[CompanyName] = """ & Me![cboCompanyName]
& """"
as will this:

Me.RecordsetClone.FindFirst "[CompanyName] = " & chr(34) &
Me![cboCompanyName] & chr(34)

But his suggestion of searching by CompanyID is best.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Nov 15 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.