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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error with Apostrophe in control 1

Status
Not open for further replies.

Bronte1226

Technical User
Oct 18, 2002
123
US
I have a form that searches on just one field of a particular table. You type in the word in a text box and the closest match appears on the text box below. If the user wants to open that record, there is a command button that they push to close the current form and open another form with the entire record. Everything works perfectly EXCEPT when the user tries to open a form that has an apostrophe in the name. What am I missing?

Private Sub OpenRecord_Click()
On Error GoTo Err_OpenRecord_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_Vendor_Qry"

stLinkCriteria = "[Vendor Name]=" & "'" & Me![FirstVendor] & "'"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenRecord_Click:
Exit Sub

Err_OpenRecord_Click:
MsgBox Err.Description
Resume Exit_OpenRecord_Click

End Sub
 
Thanks Duane! That's it!! So it was the usage of single quote/ double quote that was causing the issue then?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top