Bronte1226
Technical User
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
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