How do I create a report for only the current record?

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

I am sure this is a dumb question, but I have been unable to find the answer
in the help files,

I have a form that I want to print the report for only the current page, (
the user has to print and sign the form.) When I make a report using the
wizard, I get all the records in the database. I would like to just put a
print button on the page and print only this page. I have a button now, but
I get all the records.
thank you for you help
Michael
 
Thank you Allen
I had just found this before I saw your message, I have tried to get it to
work, but when I press the print button, nothing happens.

I have the following, I had to change to "cmdPrint_DblClick" (as when I used
"cmdPrint_Click()" I received an error that stated their was a problem with
using it. I have changed to acViewNormal as I already have a preview that
works using the code below... could the preview be causing the problem?

thank you for your help
Michael



Private Sub cmdPrint_DblClick(Cancel As Integer)
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[IrrigazioneID] = " & Me.[IrrigazioneID]
DoCmd.OpenReport "SchedaIrrigazioneM75F", acViewNormal, , strWhere
End If
End Sub


Preview button

Private Sub Command83_Click()
On Error GoTo Err_Command83_Click

Dim strDocName As String
Dim strWhere As String
strDocName = "SchedaIrrigazioneM75F"
strWhere = "[IrrigazioneID]=" & Me!IrrigazioneID
DoCmd.OpenReport strDocName, acPreview, , strWhere
Dim stDocName As String

Exit_Command83_Click:
Exit Sub

Err_Command83_Click:
MsgBox Err.Description
Resume Exit_Command83_Click

End Sub
 
Well this is a real duh answer to the last post.. when I clicked on the
button nothing happened because I had set it to double click. When I double
click it prints, but is there a reason that a single click does not work?
thank you
Michael

Michael said:
Thank you Allen
I had just found this before I saw your message, I have tried to get it to
work, but when I press the print button, nothing happens.

I have the following, I had to change to "cmdPrint_DblClick" (as when I
used "cmdPrint_Click()" I received an error that stated their was a
problem with using it. I have changed to acViewNormal as I already have
a preview that works using the code below... could the preview be causing
the problem?

thank you for your help
Michael



Private Sub cmdPrint_DblClick(Cancel As Integer)
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[IrrigazioneID] = " & Me.[IrrigazioneID]
DoCmd.OpenReport "SchedaIrrigazioneM75F", acViewNormal, , strWhere
End If
End Sub


Preview button

Private Sub Command83_Click()
On Error GoTo Err_Command83_Click

Dim strDocName As String
Dim strWhere As String
strDocName = "SchedaIrrigazioneM75F"
strWhere = "[IrrigazioneID]=" & Me!IrrigazioneID
DoCmd.OpenReport strDocName, acPreview, , strWhere
Dim stDocName As String

Exit_Command83_Click:
Exit Sub

Err_Command83_Click:
MsgBox Err.Description
Resume Exit_Command83_Click

End Sub




Allen Browne said:
Use the WhereCondition of the OpenReport action.

Details in:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html
 
Back
Top