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

Copy form data to a report

Status
Not open for further replies.

mclellan

Programmer
Aug 6, 2002
294
CA
Hello,

I have a form with 2 sub forms in it and need to create a report from this data.

Is there any easy way to just pass the data currently on the screen to a report, or do I need to make my own query (basically emulating the form) and create the form based off of this?

Thanks!
Barry
 
Do you mean something like:
[tt]DoCmd.OpenReport "rptReport",,,"ID=" & Me.ID[/tt]
Or
[tt]DoCmd.PrintOut ...[/tt]
Or
[tt]DoCmd.OutputTo ... ?[/tt]

It is usually best to create a report that mirrors the form.
 
Hi Remou,

Sorry, my newbie status is showing. I was hoping there would be some kind of wizard that would grab all of my form data, including my muliple sub-forms and move that to a report for me.

Thanks!
Barry
 
The code below is the nearest you will get to one click, but I don't recommend it, it can get very messy printing forms. It is quite easy to build a report when you have the form to refer to.

Except for the filter, this is wizard generated. It goes in the form's module:

Code:
Private Sub cmdPrint_Click()
On Error GoTo Err_cmdPrint_Click

'Filter to print the current record
    DoCmd.ApplyFilter , "ID=" & Me.ID
'Print the current form
    DoCmd.PrintOut

Exit_cmdPrint_Click:
    Exit Sub

Err_cmdPrint_Click:
    MsgBox Err.Description
    Resume Exit_cmdPrint_Click
    
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top