Attn: Ken Snell

B

Bill

Thanks for your help but it doesn't work.

I got message error in Module. It show "BOLD" as Replace. I am not too sure how to fix it.

******************************************************************

Put the following function in a regular module:

Public Function SingleQDouble(ByVal xstrReplaceStringValue) As String
'***THIS FUNCTION CONVERTS ONE SINGLE-QUOTE CHARACTER INTO TWO SINGLE-QUOTE
'***CHARACTERS IN A TEXT STRING.

' xstrReplaceStringValue is string variable that contains the text string
that
' needs to be converted

SingleQDouble = Replace(xstrReplaceStringValue, "'", "''")
End Function


Then change your expression in the post to this:

"Table1.cboCity = '" & SingleQDouble(cboCity) & "' And Table.Country ='" &
SingleQDouble(cboCountry) & "'"

This function replaces a single ' with two ' characters, which ACCESS will
then correctly interpret as a single ' in the text string.

--
Ken Snell
<MS ACCESS MVP>

Hi,

I create two dropdownmenu for list of city and country. It works if I
select other city without single quote but it will not work with single
quote . I am trying to add Chr(34) to make it work. Your help would be
much appreciated.

example. St. Paul's

"Table1.cboCity = '" & cboCity & "' And Table.Country ='" & cboCountry & "'"
 

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