(2007) easiest way to include query criteria in a query form

weeblebiker

Registered User.
Local time
Today, 11:47
Joined
May 27, 2010
Messages
70
build your query and build the form /report the query info dumps into
add one unbound fields for a single criteria or two unbound field for a range like a date range to the form or report, name the fields (ex: date1 and date2) change the tab order to start with the unbound field,for a range put the beginning field first and the ending field second tab order

go back to your query and in the criteria line for the select field enter
(for specific criteria): [Forms]![form name]![unbound field name]
(for a range): Between ([Forms]![form name]![unbound field name]) And ([Forms]![form name]![unbound field name])

go back to the form
right click the last unbound field, then click "properties" and click on the "event" tab go down to "lost focus" click the little "..." box in the action column click the arrow button and select "requery"

now when you open the form all the fields are blank because the query had no criteria to run.
the first select field will contain the cursor, enter the criteria and when you hit tab (lost focus) the query re runs and populates the form leaving the criteria entered visible because the field is unbound. the requery also puts the cursor back in the first field.

left click on the little circle icon in the top left corner click on the "access options" button and go to "advanced" and select "move after enter"= "next field" and 'Behavior entering field" = "select entire field"

now when you open the form the first criteria field is highlighted, enter the criteria, hit tab or enter and the form populates and the criteria field is highlighted again to enter new criteria.
 
Tried to set it up exactly as you mentioned but the query still returns no data which is not right as there is data in the table which matches the criteria.
 
then you did something wrong?
the key is setting the the query to look at the unbound field on the form or report for the select criteria and setting the unbound field to "requery" on lost focus.
 
I managed to figure it out. I had not realized that the default was to bind column 1 were the data I was asking it to sort through was in column 2. Stupid mistake.
 

Users who are viewing this thread

Back
Top Bottom