Syntax Error

  • Thread starter Thread starter blake7
  • Start date Start date
B

blake7

Hi all, can anyone spot the syntax error in the code below, its driving me
mad !!
Thanks


Private Sub FilterUIN_Click()
If Me![FilterUINText].Value = "" Then
Me.SERDatasheet.Form.FilterOn = False
Else
Me.SERDatasheet.Form.Filter = "boiler uin like'*" &
Me![FilterUINText].Value & "*' or Desc like '*" & Me![FilterUINText].Value &
"*'"
Me.SERDatasheet.Form.FilterOn = True
End If


End Sub
 
Blake7 -

I suspect "boiler uin" is the name of a field since it is before 'like'. If
so, it needs square brackets due to the space in the fieldname. Try this:

Private Sub FilterUIN_Click()
If Me![FilterUINText].Value = "" Then
Me.SERDatasheet.Form.FilterOn = False
Else
Me.SERDatasheet.Form.Filter = "[boiler uin] like'*" &
Me![FilterUINText].Value & "*' or Desc like '*" & Me![FilterUINText].Value &
"*'"
Me.SERDatasheet.Form.FilterOn = True
End If
 
Thanks Guys, should have spotted that, brain freeze!!
Regards

Douglas J. Steele said:
There's a space in your field name. Change to

"[boiler uin] like'*"

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

blake7 said:
Hi all, can anyone spot the syntax error in the code below, its driving me
mad !!
Thanks


Private Sub FilterUIN_Click()
If Me![FilterUINText].Value = "" Then
Me.SERDatasheet.Form.FilterOn = False
Else
Me.SERDatasheet.Form.Filter = "boiler uin like'*" &
Me![FilterUINText].Value & "*' or Desc like '*" & Me![FilterUINText].Value
&
"*'"
Me.SERDatasheet.Form.FilterOn = True
End If


End Sub


.
 
Also missing space between Like and quote marks

Private Sub FilterUIN_Click()
If Me![FilterUINText].Value = "" Then
Me.SERDatasheet.Form.FilterOn = False
Else
Me.SERDatasheet.Form.Filter = "[boiler uin] like '*" &
Me![FilterUINText].Value & "*' or Desc like '*" & Me![FilterUINText].Value &
"*'"
Me.SERDatasheet.Form.FilterOn = True
End If

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
Back
Top