Button on Form to Run Report based on Query with Parameters

P

Peter Kolbe

Hi Guys.

I am busy working on a stock control database (and job control).

When I have a Form Open, it shows several fields, including JobID (Which is
the PK for that job) (frm_Invoicing)

I also have a Query that when Run, it prompts for the JobIDNo.
(qry_CustJobsInvStock)

I have a report based on that query. (rpt_CustJobsInvStock)

I have added a button onto the form (onclick -> DoCmd.OpenReport) to open
and automatically print the report,

But I just cannot figure out how to get it to get my JobID from the form,
and to Automatically add it as a Parameter for the query. I.E. i still have
to type in the JobIDNo by hand.


Please Help

Peter



--- news://freenews.netfront.net/ - complaints: (e-mail address removed) ---
 
G

ghetto_banjo

in your query, you can directly reference the form fields (note if you
use this query elsewhere when the Form is not open, it wont work(.


Forms![formname].[fieldname]

i.e.

Forms!frm_Invoicing.JobID
 
P

Peter Kolbe

Thanks Ghetto

Works like a Bomb (but at least it does not blow up)

P

ghetto_banjo said:
in your query, you can directly reference the form fields (note if you
use this query elsewhere when the Form is not open, it wont work(.


Forms![formname].[fieldname]

i.e.

Forms!frm_Invoicing.JobID



--- news://freenews.netfront.net/ - complaints: (e-mail address removed) ---
 
D

Duane Hookom

I typically remove all dynamic criteria from queries that are record sources
for forms and reports. I get all user input from controls on forms and then
use the WHERE CONDITION argument of DoCmd.OpenReport. This method doesn't tie
any report to any form.

--
Duane Hookom
Microsoft Access MVP


Peter Kolbe said:
Thanks Ghetto

Works like a Bomb (but at least it does not blow up)

P

ghetto_banjo said:
in your query, you can directly reference the form fields (note if you
use this query elsewhere when the Form is not open, it wont work(.


Forms![formname].[fieldname]

i.e.

Forms!frm_Invoicing.JobID



--- news://freenews.netfront.net/ - complaints: (e-mail address removed) ---
.
 
S

sduis

Peter Kolbe said:
Hi Guys.

I am busy working on a stock control database (and job control).

When I have a Form Open, it shows several fields, including JobID (Which
is the PK for that job) (frm_Invoicing)

I also have a Query that when Run, it prompts for the JobIDNo.
(qry_CustJobsInvStock)

I have a report based on that query. (rpt_CustJobsInvStock)

I have added a button onto the form (onclick -> DoCmd.OpenReport) to open
and automatically print the report,

But I just cannot figure out how to get it to get my JobID from the form,
and to Automatically add it as a Parameter for the query. I.E. i still
have to type in the JobIDNo by hand.


Please Help

Peter


--- news://freenews.netfront.net/ - complaints: (e-mail address removed) ---
 

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