November 5th, 2012, 11:57 AM
VB code to print only page 1
I could sure use your help with the VB code to print only one page, the details are below:
Report name: SHEMA Form
Presently I have a button that uses the following code, but the report prints a duplicate page for each of the line items associated with the "Key" field, which is "PRNumTemp".
Private Sub Command12_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
strWhere = "PRNumTemp = '" & Me.PRNumTemp & "'"
DoCmd.OpenReport "SHEMA Form", acViewReport, , strWhere
So if you have a good suggestion, I'm all ears, but at least provide the code for printing only one page, please and thank you.
November 5th, 2012, 03:46 PM
Here is a line of code I have used to print just one page of a report.
ID is the control name in the report and references the control in my form that I want to print.
DoCmd.OpenReport stDocName, acViewPreview, , "[ID]=Forms!frmClients!ID"
I'm not sure what is causing your db to print twice.
Office 2010, 2007, 2002
If I helped you, then click "give rep" button in the lower left corner.
November 5th, 2012, 05:52 PM
The duplication is probably because of the RecordSource. There are multiple tables? Is there one or more join clauses in the SQL statement? Is this query including more than one 'many' table joined to the 'one' table?
Alan, might be a typo in your code sample as it has the variable within quote marks instead of concatenating. It does look like OP is trying to limit report to a single record by using unique value criteria.
Last edited by June7; November 5th, 2012 at 10:04 PM.