Query input from form

J

Jasper Recto

I have a query that needs input from a form to filter the data. The query
field can be either a -1 or a 0.

On the form, I have a combo box that has a value list. The list consist of
"Quoted" or "Not Quoted"

How can I point the query filter to that form combo box and pass a value of
either -1 or 0?

Also, how would I do it if they left the combo box empty so that both
"Quoted" and "Not Quoted" records are selected.

Is a combo box the best thing to use in this scenario?

Thanks,
Jasper
 
G

Guest

Jasper Recto said:
I have a query that needs input from a form to filter the data. The query
field can be either a -1 or a 0.

On the form, I have a combo box that has a value list. The list consist
of "Quoted" or "Not Quoted"

How can I point the query filter to that form combo box and pass a value
of either -1 or 0?

Also, how would I do it if they left the combo box empty so that both
"Quoted" and "Not Quoted" records are selected.

Is a combo box the best thing to use in this scenario?

Thanks,
Jasper
 
J

John Spencer

SELECT *
FROM SomeTable
WHERE (SomeField = (Forms!YourFormName!YourControlName = "Quoted")
OR Forms!YourFormName!YourControlName is Null)

If you are entering that into the design view then enter the following
in the criteria for your field:
(SomeField = (Forms!YourFormName!YourControlName = "Quoted") OR
Forms!YourFormName!YourControlName is Null)

Access WILL rearrange that when you close the query, but it should still
work unless you have too many other criteria you are applying.


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
J

Jasper Recto

John,

There are 3 options here. The user can either pick "Quoted", "Not Quoted"
or "All".

How would I do this?

Thanks,
Jasper
 
J

John Spencer

Slight modification to the query should work

SELECT *
FROM SomeTable
WHERE (SomeField = Forms!YourFormName!YourControlName
OR Forms!YourFormName!YourControlName = "All")

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top