Form Querying

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a front page for a database used to run queries and reports.
On the front page I have a combo box, to enable the user to choose the Unit
(i.e. manufacturing unit at chemical plant) and under the combo box I have a
comand button set up. I want the user to choose the unit from the combo box
and then bus the button and the report show up for that particular unit. I
have not been able to get the two in sync. I know this can be done I just
can't figure it out. The report that is set up contains all units, how do I
make it pull out the information for just the unit choosen from the combo
box. Thanks!
 
You could do something like:

Private Sub cmdReport_Click()
DoCmd.OpenReport "rptMyReportName", acPreview, "",
"[tblMyTableName]![MyUnitFieldName]=[Forms]![frmMyForm]![cboBoxControlName]"
End Sub

Or skip the command button and just apply the code to the AfterUpdate event
for the combo box.
 
Thank you very much, that worked. Now one more question what if I only want
it to pull up information from a certain date range per unit. Right now I
just added the code to the AfterUpdate event and deleted the command button,
but can I make it specify a date range to pull up. There is a field in the
report called date occurance and that is what I would want it to look at.
Thank you!!
 
If the report is based on a query you can add some criteria to filter out the
date range something like this in the query design:

In the criteria row for the date occurrance field...

Between [Enter start date] and [Enter end date]

Didn't try this but seems logical that you could add to the earlier
statement....

Private Sub cmdReport_Click()
DoCmd.OpenReport "rptMyReportName", acPreview, "",
"[tblMyTableName]![MyUnitFieldName]=[Forms]![frmMyForm]![cboBoxControlName]
and [tblMyTableName]![date occurance] Between [Enter start date] and [Enter
end date]"
End Sub
 

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

Similar Threads


Back
Top