Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a Customized Report from a Form

Status
Not open for further replies.

MilinPCH

Technical User
Jul 27, 2000
37
US
I know this is probably a no-brainer, but I've never done it before..I just need to see what the VBA code looks like and I can go from there...

I have a product invoice report - based on a query that asks the user for a company name and an invoice date. It works perfectly. What I want to do is create a button on the form that the user enters items to be sold. ie... when the user runs the report from this form, the questions in the query about company name and date are automatically filled in from those fields that are already present on the current form. Did I make sense?

Thanks
 
Hi!

Do you by this mean that you want the same report (well actually query) to retrieve the values from the form, if its open, or retrieve them through parameters if not?

If this is the case, my approach is to create to nearly identical queries, where one query uses the parameters you've alredy created.

The other one, fetches the criteria from the form by the syntax; forms!frmYourForm!fldOne

Then in your reports "on open" event, check whether the form is open, and set the reports recordsourse accordingly.

If "Your form is open" then
me.recordsource="qryParamFromForm"
Else
me.recordsource="qryParam"
Endif

Have fun, Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top