Combo Box relating to Variable Criteria in Query

labbadabba

Registered User.
Local time
Today, 11:34
Joined
Nov 16, 2005
Messages
19
I have an unbound Combo Box in a form that I would like to use to set criteria in the query. How do I do this?
 
The easiest way is:

Criteria:
Forms![YOURFORMNAME]![cboYOURCOMBONAME]

But not the best way. I don't like to bind queries to forms.

I prefer to create a function to pass the control value to on an event.

Code:
Public COMBOval As String

Public Sub SetCOMBOval(myCOMBO As Variant)
    
    If IsNull(myCOMBO) Then
        COMBOval = ""
    Else
        COMBOval = myCOMBO
    End If

End Sub

Public Function GetCOMBOval()

    GetCOMBOval = COMBOval
    
End Function

Changing the name COMBO to something you can use, e.g. PartDescription
Then using:

GetCOMBOval()

as your criteria.

I can expand on this if needed.

Hope that helps.

Cheers,
 
Interesting...I'll give that a shot. Thanks.
 

Users who are viewing this thread

Back
Top Bottom