Pass information from form to QUERY CRITERIA

K

kealaz

I have a macro [mcPO] that executes when I click on a command button
[Issue
Purchase Order]. This macro saves and closes a form [frmPO_ISSUE] and
then
opens a report [rptPO].

rptPO is based on a query [qryPOCopy].

When qryPOCopy is run, a pop-up window appears asking for a PO Number
(
Criteria = [Enter PO Number:] ). Then it searches two tables
[tblPOHIST and
tblBUYHIST] to find the information it needs to create the report.

My question is...

Since the PO number [text box name: P_O_NO] I want to use for the
report/query is in the form that I am save/closing, can I pass that
information automatically to the query by either adding some code to
the ON
CLICK event of my command button [Issue Purchase Order] or by adding
to the
macro that calls the report?

Thank you very much for any and all help you can provide. I greatly
appreciate all the help I get from this forum.
 
D

Dale Fye

The easiest way to do this is to have the query that the report is based on
point to the control on your form, something like:

SELECT A.*, B.*
FROM Table1 as A INNER JOIN Table2 as B
ON A.ID = B.ID
WHERE A.PO_Num = Forms!yourFormName.ControlName

The down side of this is that the form needs to be open when the report is
run, so instead of closing the form after the Click event, just hide it and
open the report.
 

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