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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create report from form with VBA 2

Status
Not open for further replies.

44nato44

Programmer
Dec 12, 2008
115
NL
Hi

I have a form with some subforms which has some queries which I need to get printed out, the best way is to make a report from the form.

My goal is to save my form as a report and print it out with some VBA code.

I can do it manually, but would like to have a button on my form which can do it.

Anybody can help ?
 
Why would you need to create the report more than once? Don't you simply want to display different records? Doesn't the report design (controls, sections,...) stay exactly the same?

Duane
Hook'D on Access
MS Access MVP
 
I am not sure what you mean, I got a form with 3 queries which come from a dropdown on the form.

It is that data I though would be best to save as a report and then print it out.

As if I want to print it out on my form, the data is all over the place :(
 
The form is not the data and doesn't store the data. It only displays the data. Can we assume you only want to save the data values and then display them in a report?

Does the arrangment of the controls on the report need to change or just the data?

Duane
Hook'D on Access
MS Access MVP
 
I can do it manually, but would like to have a button on my form which can do it.

How do you do it manually?
Do you all ready have the report designed?

Put the code in the Click event of your button.
Code:
DoCmd.OpenReport "MyReport"

Randy
 
dhookom
The data is what will change, and then it should print that.

All controls stay the same
randy700
I am looking to save a report not open one from the form, not sure if this is possible with vba



Thanks guys
 
44nato44,
I don't think you understand reports and forms. Forms and reports only display values. They do not store values. Values are generally stored in tables and then rendered/displayed in forms and reports. You do not need a new report to display different values. The record soruces of forms and reports determine the records and fields that get displayed.

All you should need to do is change the filtering of the data in your report to display different records. There are many methods available for changing/filtering the records in your report's record source.

Can you please tell us about your tables and what you want to display in your report?

Duane
Hook'D on Access
MS Access MVP
 
Probably not :)

My end goal is to print either the form or a report made from the form.

the form holds the data it should, it has a drop down which changes some labels on the form and some subqueries.

I noticed now that when I print it prints the form for all values in the drop down.. is that normal ?

I never printed from ms access before.
 
Code:
[i]DoCmd.OpenReport "MyReport"[/i]
I am looking to save a report not open one from the form
My end goal is to print either the form or a report
Did you even TRY the code?



Randy
 
You can select a form in the database window and save it as a report. All data reporting should always use a report. IMO, never print a form.

A report is similar to a form in that it has a Record Source, sections, and controls. Forms can "host" subforms and Reports can host subreports.

Just try select your datasource table or query and step through the report creation wizard. This should get you going in the proper direction.

Come back if you need more help. Please be specific about your record source fields and needs in your report.

Duane
Hook'D on Access
MS Access MVP
 
Thanks for all your inputs,

I was hoping that I did not need to create a report, but it seems that I needed to.

So I created my report which grapped some values from my form and that all seems to work.

Thanks a lot for your help guys.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top