Full Version: Select Query Using Combo Box
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
BillR
I want to set the criteria of a query by the use of a combo box. I'm not sure where to begin with this... Can anyone point me in the right direction?
jleach
Hi,

Depending on the context, a few ways would be to use the Expression Services to reference the combo from your query:

CODE
SELECT * FROM SomeTable WHERE SomeField = [Forms]![FormName]![ComboBoxName]


or maybe use the AfterUpdate event of the combo to build a dynamic SQL statement:

CODE
Dim strSQL As String

strSQL = "SELECT * FROM SomeTable WHERE SomeField = """ & Me.ComboBoxName & """"

someobject.Recordsource = strSQL


hth
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.