Query input from form

  • Thread starter Thread starter Jasper Recto
  • Start date Start date
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
 
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
 
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
'====================================================
 
John,

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

How would I do this?

Thanks,
Jasper
 
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
'====================================================
 
Back
Top