Attaching a Query to a Form

Consider

New member
Local time
Today, 10:42
Joined
Oct 27, 2011
Messages
3
Hello, I'm very new to Access, and have been tasked with what seems to be a simple solution.

I have a table in my database for products. Feilds in the database are UPC, Prod Desc, Start Date, End Date.

I want to have a simple form to where the user enters a UPC in a textbox, clicks the Search Button and the results are displayed on the same form. The results need to be read only.

I was able to set up the Query without any problems, but I don't know how to attach everything together in the form. So the info from the textbox gets sent to the Query as the filter critera and the results are sent back to the form (I'm thinking into a list box).

Any help would be appreciated in pointing me in the proper direction.
 
Hello, I'm very new to Access, and have been tasked with what seems to be a simple solution.

I have a table in my database for products. Feilds in the database are UPC, Prod Desc, Start Date, End Date.

I want to have a simple form to where the user enters a UPC in a textbox, clicks the Search Button and the results are displayed on the same form. The results need to be read only.

I was able to set up the Query without any problems, but I don't know how to attach everything together in the form. So the info from the textbox gets sent to the Query as the filter critera and the results are sent back to the form (I'm thinking into a list box).

Any help would be appreciated in pointing me in the proper direction.

Hi,

A quick idea for you would be to have a combobox which looks up the UPC from your table. Then have the Record Source for the form which filters the results based on the combobox

Then all you need to do is requery the form after the combo changes.

Hope this helps.
 
Hi,

A quick idea for you would be to have a combobox which looks up the UPC from your table. Then have the Record Source for the form which filters the results based on the combobox

Then all you need to do is requery the form after the combo changes.

Hope this helps.


A combobox will work too. The problem I'm having now is passing the value of the combobox to the query, and then getting the results to display in the list box. I'm totally lost on this step.
 
In the criteria in the query for the field to be filtered you need to enter similar to this:

[Forms]![YourFormName].[YourComboBoxName]

depending on how you set up your combo box, you may need to join the lookup table in the query to ensure that you get the right results and not a datatype mismatch.

Alan
 
In the criteria in the query for the field to be filtered you need to enter similar to this:

[Forms]![YourFormName].[YourComboBoxName]
... and put Me.Requery in the After Update event of the combo box.

However, the ideas posed will only work for a Single Form or Continuous Form. If you want to have the Combo Box in the Header section of the main form and then display a Datasheet in the detail section, you will need a subform placed in the Detail section of the main form and then filter the subform's record source using its Filter and Filter On properties.
 

Users who are viewing this thread

Back
Top Bottom