Forum Discussion
Very Confused by Run Time error '3075' - Help !!
Good Afternoon
I have a 3 line piece of code in my After Update for a Combo-Box which has always worked in the past,
I am creating a new DB this morning and utilized the same code, and am now getting a run time error 3075 and the following message :-
Syntax error (Missing Operator) in query expression ' [Location]='Belem Val de Cans / Julio Cezar Ribeiro Int'l - SEBE".
The code is :-
Private Sub Combo25_AfterUpdate()
Me.Filter = "[Location]= ' " & Me.Combo25 & " '"
Me.FilterOn = True
Me.Combo25 = Null
Would anybody have any ideas ?
Many Thanks
Adrian
- Karl
Many Many Thanks, something as simple as that !!
Best Regards
Adrian
Hi,
The error occurs because the string passed to the filter contains a single quote in "Int'l". As the single quote is also used to delimit the complete string it is terminated after "int" and the remaining string leads to the error. There are several methods to cure this. One is to use double quotes as delimiter, e.g. like this:
Me.Filter = "[Location]= " & Chr$(34) & Me.Combo25 & Chr$(34)
However, if your strings can also contain double quotes then you'll get the same problem with these again. So, it may be more secure to double the trouble maker and thereby escape it:
Me.Filter = "[Location] = '" & Replace(Me.Combo25 , "'", "''") & "'"
Servus
Karl
****************
Access Forever
Access News
Access DevCon
Access-Entwickler-Konferenz AEK- Cinders01Copper ContributorKarl
Many Many Thanks, something as simple as that !!
Best Regards
Adrian