View Full Version : Error 3075: using BuildCriteria


brpallet
03-13-2009, 09:17 PM
I am trying to filter a datasheet form using a combo box and have not had any success. The combo box is located in the form header and the code is tied to the change event.

I keep getting the following error.
Run-time error '3075':
Syntax error (missing operator) in query expression 'Production
Source="Secondary'".

Here is the code.
Private Sub Combo19_Change()
Dim strFilter As String

' Build criteria string.
strFilter = BuildCriteria("Production Source", dbText, Combo19)

' Set Filter property to apply filter.
Me.Filter = strFilter

' Set FilterOn property; form now shows filtered records.
Me.FilterOn = True

End Sub


Thank you for any help,
Michael

ajetrumpet
03-13-2009, 10:10 PM
drop the build criteria, and replace it with this:strFilter = "[production source] = '" & me.combo19 & "'"

raskew
03-14-2009, 05:15 AM
The BuildCriteria() function will work just fine:

Change:
strFilter = BuildCriteria("Production Source", dbText, Combo19)

To:
strFilter = BuildCriteria("Production Source", dbText, me.Combo19)

Bob

brpallet
03-14-2009, 06:26 AM
Thank you for the replys. Droping the Build Criteria worked great!

I tried adding the "Me." before the combo19 but recieved the same error. Got any ideas why the build criteria don't work?

raskew
03-14-2009, 07:23 AM
Hi -

Here is a sub that I use that works perfectly:

Private Sub cboDisplay_AfterUpdate()
Dim strFilter As String
Dim strType As String

strType = Choose(Me.OptDisplay, "", "CatID", "VendID", "HowPaidID")
' Build criteria string.
strFilter = BuildCriteria(strType, dbLong, Me.cboDisplay)

' Set Filter property to apply filter.
Me.Filter = strFilter
' Set FilterOn property; form now shows filtered records.
Me.FilterOn = True
Me.Requery
Me.cboDisplay.Visible = False
End Sub

...where Me.OptDisplay is an option group.

How is your combo set up? Does it have a hidden bound column (PK)?
If so, its value would be an integer, not a string.

If you'd like to post your db I'd be happy to take a look.

Bob