ComboBox to Choose which field in a query to write the criteria (1 Viewer)

Ahmeds

New member
Local time
Tomorrow, 04:14
Joined
Apr 5, 2016
Messages
4
Good day everyone,

I am developing a simple Access program for my cousins Bus Company and he ask me to help him with the Preventive Maintenance Services

I am creating a report that depends the input from a combo box in a form.

Lets say i have 30 fields in the query, field1 is the to do list... field2 is for requisition... field3 is the priority (like change parts of the engine)... the remaining fields are the cycle of maintenance periods that defends on those kilometers that has been consumed like (12,000km, 24,000km, 36,000km, etc)

my problem is that how to do a condition(VB code) that put my <> No criteria on the field that i choose from combo box.

Note..
The remaining fields are all just check box in the the form (Yes/No in the table)..

Maybe there is someone here already did the same in their previous programs.

Can anyone help me please

Thanks in advance.
 

Ranman256

Well-known member
Local time
Today, 16:14
Joined
Apr 9, 2015
Messages
4,337
You don't put no criteria in the query.
You have boxes on the form, user pick the ones they DO want to search, then the code must check them all to see what is to be searched....
Code:
Sub btnFind_click()
  Dim sSql as string
If not isNull(cboCity) then sSql = sSql & " and [city]='" & cboCity & "'"
If not isnull(cboMaint) then sSql = sSql & " and [maintenance]='" & cboMaint & "'"
...
'Remove 1st AND
sSql = mid(sSql,5)
'Apply the where
Me.filter= sSql
Me.filterOn= true

End sub
 

Users who are viewing this thread

Top Bottom