ok, i have read tons of posts about the "apostrophe problem" but to no avail, they do not seem to help me.
i have a form with a text box that searches a table for scholarship account titles. the field is called AccountTitle. then i have a "Find Next" button that, well, finds the next occurence of the search string, in this case, the account title. the problemo is that some account titles have apostrophes in them and i receive "Run-time error '3077': Syntax error (missing operator) in the expression".
This is the code behind the text box:
Private Sub txtFind_AfterUpdate()
On Error GoTo Err_txtFind_AfterUpdate
Dim stResponse As String
stResponse = txtFind
If stResponse = "" Then
GoTo Proc_Exit
Else
stFindCriteria = "[AccountTitle] Like '*"
stFindCriteria = stFindCriteria & stResponse & "*'"
End If
Me.fsubMaintainAccounts.Form.RecordsetClone.FindFirst stFindCriteria
If Me.fsubMaintainAccounts.Form.RecordsetClone.NoMatch Then
MsgBox "Search text was not found."
stFindCriteria = ""
Else
Me.fsubMaintainAccounts.SetFocus
Me.fsubMaintainAccounts.Form.Bookmark = Me.fsubMaintainAccounts.Form.RecordsetClone.Bookmark
End If
Err_txtFind_AfterUpdate:
Exit Sub
Proc_Exit:
Exit Sub
End Sub
This is the code behind the "Find Next" button:
Private Sub cmdFindNext_Click()
If stFindCriteria = "" Then
GoTo Proc_Exit
Else
Me.fsubMaintainAccounts.Form.RecordsetClone.FindNext stFindCriteria
If Me.fsubMaintainAccounts.Form.RecordsetClone.NoMatch Then
MsgBox "Search text was not found."
stFindCriteria = ""
Else
Me.fsubMaintainAccounts.SetFocus
Me.fsubMaintainAccounts.Form.Bookmark = Me.fsubMaintainAccounts.Form.RecordsetClone.Bookmark
End If
End If
Proc_Exit:
Exit Sub
End Sub
For example, if i type "Int'l Assoc. Scholarship" in the text box nothing happens, i don't even receive an error. but when i click the "Find Next" button, that's when i get the aformentioned error.
if someone could be so kind as to check this out and pass on any help, i would be greatly aprreciative.
post script:
i would like not to have to replace the apostrophe with a quotation or some other character.
i have a form with a text box that searches a table for scholarship account titles. the field is called AccountTitle. then i have a "Find Next" button that, well, finds the next occurence of the search string, in this case, the account title. the problemo is that some account titles have apostrophes in them and i receive "Run-time error '3077': Syntax error (missing operator) in the expression".
This is the code behind the text box:
Private Sub txtFind_AfterUpdate()
On Error GoTo Err_txtFind_AfterUpdate
Dim stResponse As String
stResponse = txtFind
If stResponse = "" Then
GoTo Proc_Exit
Else
stFindCriteria = "[AccountTitle] Like '*"
stFindCriteria = stFindCriteria & stResponse & "*'"
End If
Me.fsubMaintainAccounts.Form.RecordsetClone.FindFirst stFindCriteria
If Me.fsubMaintainAccounts.Form.RecordsetClone.NoMatch Then
MsgBox "Search text was not found."
stFindCriteria = ""
Else
Me.fsubMaintainAccounts.SetFocus
Me.fsubMaintainAccounts.Form.Bookmark = Me.fsubMaintainAccounts.Form.RecordsetClone.Bookmark
End If
Err_txtFind_AfterUpdate:
Exit Sub
Proc_Exit:
Exit Sub
End Sub
This is the code behind the "Find Next" button:
Private Sub cmdFindNext_Click()
If stFindCriteria = "" Then
GoTo Proc_Exit
Else
Me.fsubMaintainAccounts.Form.RecordsetClone.FindNext stFindCriteria
If Me.fsubMaintainAccounts.Form.RecordsetClone.NoMatch Then
MsgBox "Search text was not found."
stFindCriteria = ""
Else
Me.fsubMaintainAccounts.SetFocus
Me.fsubMaintainAccounts.Form.Bookmark = Me.fsubMaintainAccounts.Form.RecordsetClone.Bookmark
End If
End If
Proc_Exit:
Exit Sub
End Sub
For example, if i type "Int'l Assoc. Scholarship" in the text box nothing happens, i don't even receive an error. but when i click the "Find Next" button, that's when i get the aformentioned error.
if someone could be so kind as to check this out and pass on any help, i would be greatly aprreciative.
post script:
i would like not to have to replace the apostrophe with a quotation or some other character.