Query question about check boxes

npa3000

Member
Local time
Today, 10:45
Joined
Apr 16, 2021
Messages
36
Hi there!

I have a table which i store my invoices which are divided into 3 categories.
I distinguish them, depending on the value of a field is 1, 2 or 3.

Also, I have a form in which I have 3 check boxes, corresponding to the 3 different invoice categories and I want to make a query in which:

Lets say, if I have selected the first check box (TRUE) IT WILL only show me the category 1 invoices. If I have selected the first and the third check box it will show me the category 1 and 3 invoices etc etc...

I quote you my sql query that does not look to work... Any ideas?

Code:
SELECT INVOICES.*
FROM INVOICES
WHERE
And (INVOICES.INVOICE_TYPE = 1 and Forms![FullPaymentInvoiceForm]!CheckInvoice =  true)
And (INVOICES.INVOICE_TYPE = 2 and Forms![FullPaymentInvoiceForm]!CheckCredit =  true)
And (INVOICES.INVOICE_TYPE = 3 and Forms![FullPaymentInvoiceForm]!CheckProforma =  true);
 
Should not have the first And ?
Plus the others should be Or ?
 
a query cant make the decisions, so use a filter.
make a continuous form that shows all records.
In the header, put unbound controls for the user to enter search criteria.
When user clicks the Find button, Test all controls for a possible filter then build the where clause:

Code:
sub btnFind_click()
sWhere = "1=1"
if not isnull(cboState) then sWhere = sWhere & " and [state]='" & cboState & "'"
if not IsNull(txtName) then sWhere = sWhere & " and [Name]='" & txtName & "'"
if not IsNull(cboGender) then    sWhere = sWhere & " and [Gender]='" & cboGender & "'"

'then filer
if sWhere = "1=1" then
me.filterOn = false
else
me.filter = sWhere
me.filterOn = true
endif
 

Users who are viewing this thread

Back
Top Bottom