Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Single Quotes in a Line of Code

Status
Not open for further replies.

vivasuzi

Programmer
Jun 14, 2002
183
0
0
Hi,

I have a line of code that (when you select from the drop down) opens up the matching record.

Here it is...

Code:
Me.RecordsetClone.FindFirst "[COMPANYname] = '" & Me![Combo28] & "'"

But then I encountered a Problem when I came to a companyname that had a single quote, so I changed it to this...

Code:
Me.RecordsetClone.FindFirst "Replace([COMPANYname], “’”, “’’”) = '" & Replace(Me![Combo28], “’”, “’’”) & "'"

Now my problem is that this doesn't work at all. If I change it to only replace in the combo it works for everything except the company names that have a single quote in them (code follows)

Code:
Me.RecordsetClone.FindFirst "[COMPANYname] = '" & Replace(Me![Combo28], “’”, “’’”) & "'"

However as I said, the above line does not work if the company has a single quote. What am I writing wrong? Please help :-D


[cat2] *Suzanne* [elephant2]
[wavey] [wiggle]
 
If the Company name will never have a double quote, you can use this:

Me.RecordsetClone.FindFirst "[COMPANYname] = " & chr(34) & Me![Combo28] & chr(34)
 
Have you tried to replace this:
Me.RecordsetClone.FindFirst "[COMPANYname] = '" & Replace(Me![Combo28], [tt]“’”, “’’”) & "'"[/tt]
By this ?
Me.RecordsetClone.FindFirst "[COMPANYname] = '" & Replace(Me![Combo28], [tt]"’", "’’") & "'"[/tt]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top