.filter statement on name with apostrophy
I have the following filter statement to narrow down to the currently logged in user.
Code:
Forms![Incidents List].FilterOn = False
Forms![Incidents List].RecordSource = "Qry_Incidents"
Forms![Incidents List].Filter = "([staff_name] like '" & username & "' or [staff_supervisor] like '" & username & "')"
Forms![Incidents List].FilterOn = True
The Staff_name and Staff_supervisor fields have some names with ' in the name like O'Brien.
I get a syntax error when it encounters one.
How can I effectively search a name like this?
Thank you,
Steve Hathaway
Re: .filter statement on name with apostrophy
You've posted I the wrong forum and we don't know what technologies you're using so the chances of you getting a useful answer are currently very low. Is this Access, SQL Server, something else. And what front end language is it? VBA, .Net?
I can tell you that in SQLServer you escape an apostrophe by putting another apostrophe in front of it. So to query for O'Brien you can say:-
Code:
Where Name = 'O''Brien'
I don't know if that's helpful to you or not though.