Error 3075: using BuildCriteria

brpallet

New member
Local time
Today, 09:59
Joined
Feb 28, 2009
Messages
7
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
 
drop the build criteria, and replace it with this:
Code:
strFilter = "[production source] = '" & me.combo19 & "'"
 
The BuildCriteria() function will work just fine:

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

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

Bob
 
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?
 
Hi -

Here is a sub that I use that works perfectly:

Code:
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
 

Users who are viewing this thread

Back
Top Bottom