Combo

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hi,

I have dropdown menu for Country, State and City. It related each other
like USA, Califorina, Los Angeles, USA, Florida, Tampa Bay, etc. I have a
problem with single quoate that get an error. Is this a right code or did
i miss anything?

vStateQuery = "select distinct State from Country_Master where State='" &
vState & "' AND Country ='" & vCountry & "'"

State.RowSource = vCityQuery

St. Paul's (get error message)

St. Paul s (it works, no single quoate)

You help would be appreciated.
Thanks
 
Hello Bill,

One way to get around this issue is not to use explicit quotation marks at
all: At the top of a module, insert the following:

Global Const vbQuote = """"
' That's 4 double quotation marks

Then, your string would look like:

vStateQuery = "select distinct State from Country_Master where State="
& vbQuote & vState & vbQuote & " AND Country =" & vbQuote & vCountry &
vbQuote

Another is to use Chr(34)

vStateQuery = "select distinct State from Country_Master where State="
& Chr(34) & vState & Chr(34) & " AND Country =" & Chr(34) & vCountry &
Chr(34)
 
Back
Top