Print Report from Form

depawl

Registered User.
Local time
Today, 02:38
Joined
May 19, 2007
Messages
144
Is it possible to print a report from a form so that it prints the current record only? In other words I have a form with a "print" command button, when I click on it I need it to print a report of the current record only.
I've set up a print button on the form but it prints all records.

Thanks.
 
Yes

You will need a query that collects all of the data for you report based on RecordID of the current record.

In the query Criteria (for RecordID) put [forms]![frm_name]![RecordID] that will select only the data relevant to the RecordID for the record currently displayed in the form.
 
Thanks John, it worked like a charm.
 
Question regarding the printing

I too am using the your solution. But I was surprised to find out that the print option went straight to mdi format.:confused: Is there a way for it to be exported into Word and then sent off to the printer?
 
Print Form view - current record only

I'm trying to follow the various forum postings to print current record only from a form (that includes 2 sub forms). I've formatted the form view in a user friendly entry view. I would like to print this same view - current record only.

Is it possible to do without recreating in a report?

current vb:
Private Sub Print_Current_Record_Click()
On Error GoTo Err_Print_Current_Record_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

Exit_Print_Current_Record_Click:
Exit Sub

Err_Print_Current_Record_Click:
MsgBox Err.Description
Resume Exit_Print_Current_Record_Click

End Sub
 
I hope this helps

I realized that I wanted to do more with the print function so I created a button that would access a MACRO that used a query to select the info I wanted (a singular entry) and then send the information to a generated report and the print the selected report.

This gave me a more customized printing of the information that I was looking for.
-------------------------------------------------

I solved this problem by adding a button:
in On Click I added a Macro entitled "mcrPrintReport"

The MACRO named "mcrPrintReport"
the macro has an "OpenReport" in the Action column

In the lower section I added
"rptLedgerInv" in the Report Name
"Print" in the View
"qryIndividualreports" in the Filter Name
"Normal" in the Window Mode

The Query named "qryIndividualreports"
Is used as a filter to identify the fields that will be used
in the report. It can contain multiple tables, to help polpulate your report. In the [contains] field of the first column I added
[forms]![frmLedger]![LedgerID]
to bind the unique ID number [LedgerID]

The Report Named "prtLedgerInv"
This is a report that can be tailored to your design "look and Feel" it's source must be a query that contains all the information/tables that the you have selected in "qryIndividualreports"
---------------------------------------------------

I hope that helps.
G:)
 
print button on form fails to print new data

I have a table and a form to do data entry. After each record is entered (only 2 fields) I want to print a small barcode label.
I created the form and placed a print command button on it.

then I attach the following vba code to the onclick event to invoke a report


Private Sub Command6_Click()
strReportName = "labelrpt"
If IsNull([meter number]) Then 'i make sure they filled the meter number in
Else
strCriteria = "[meter number] = " & Me![meter number]
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End If
End Sub

the above works if I locate an existing entry and click the button.
but I am entering new data and it must not be getting updated by the time I click the button because the report shows bogus data on the report.
How can I get the new data on the report???
Thanks in advance
Dennis
 
Just before the strCriteria line put

If Me.Dirty Then Me.Dirty = False
 
That did it!!!!!!!

Thanks Bob, I am learning as I go
There is so much to learn
God bless you.
Dennis
 
Glad we could help! And, sorry for not saying this sooner, but Welcome to Access World Forums! :)
 
I am trying to make sense of this forum

I am using the above example to create a query for my report:


In the query Criteria (for RecordID) put [forms]![frm_name]![RecordID] that will select only the data relevant to the RecordID for the record currently displayed in the form.

I would like to know what my event procedure would be for the button on my form to open the report to the specific record.

I have tried and my button calls up a parameter box.
If I type the ID into the parameter box then the report opens correctly.
I want the button to open the report and go to the record.

thanks
 
Dave:

If you have an ID field that is on the form and that same ID field is in the recordset of the report you are opening you can open it by referencing it thus:
Code:
DoCmd.OpenReport "YourReportNameHere", acViewPreview,,"[YourKeyFieldNameHere]=" & Me!YourKeyFieldNameHere
If YourKeyFieldNameHere is Text then you would need:
Code:
DoCmd.OpenReport "YourReportNameHere", acViewPreview,,"[YourKeyFieldNameHere]='" & Me!YourKeyFieldNameHere & "'"

and if your code that opens the report is on a main form but the key id field is on a subform then it would be:

Code:
DoCmd.OpenReport "YourReportNameHere", acViewPreview,,"[YourKeyFieldNameHere]=" & Me.YourSubformContainerNameHere.Form!YourKeyFieldNameHere
 
Thanks again bob

I used your 1st option and works perfect.

Although I took out the criteria in the id field of the query
That was calling up the parameter box.

Thanks
 

Users who are viewing this thread

Back
Top Bottom