I have a form with a combo box for the name and an Ok button which runs the code below. The code works fine as long as the name doesn't have an apostrophe in it. If it does then I get this message Syntax error missing operator in query expression
I am sure this has got to be something simple. Any help is greatly appreciated.
wrightie
Code:
Private Sub SearchForInfo_Click()
[FONT=Verdana][COLOR=black]On Error GoTo Err_SearchForInfo_Click[/COLOR][/FONT]
[COLOR=black][FONT=Verdana] Dim stDocName As String[/FONT][/COLOR]
[FONT=Verdana][COLOR=black] Dim stLinkCriteria As String[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] stDocName = "Info"[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] stLinkCriteria = "[Name]=" & "'" & Me![Name_ComboBox] & "'"[/COLOR][/FONT]
[COLOR=black][FONT=Verdana]DoCmd.OpenForm stDocName, , , stLinkCriteria[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Exit_SearchForInfo_Click:[/FONT][/COLOR]
[FONT=Verdana][COLOR=black] Exit Sub[/COLOR][/FONT]
[COLOR=black][FONT=Verdana]Err_SearchForInfo_Click:[/FONT][/COLOR]
[FONT=Verdana][COLOR=black] MsgBox Err.Description[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] Resume Exit_SearchForInfo_Click[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]End Sub[/COLOR][/FONT]
I am sure this has got to be something simple. Any help is greatly appreciated.
wrightie