Print form current record only with subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here is my code:

Private Sub cmdPrintRecord_Click()
On Error GoTo Err_cmdPrintRecord_Click


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

Exit_cmdPrintRecord_Click:
Exit Sub

Err_cmdPrintRecord_Click:
MsgBox Err.Description
Resume Exit_cmdPrintRecord_Click

End Sub

How do I code to only print the current record? Thanks
 
JAdams said:
Here is my code:

Private Sub cmdPrintRecord_Click()
On Error GoTo Err_cmdPrintRecord_Click


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

Exit_cmdPrintRecord_Click:
Exit Sub

Err_cmdPrintRecord_Click:
MsgBox Err.Description
Resume Exit_cmdPrintRecord_Click

End Sub

How do I code to only print the current record? Thanks


You don't give a good reason for using the PrintOut method
on a form, which is ill suited to printing. Instead, you
should use a report to format and print the data. Use the
OpenReport method, which has the WhereCondition argument
that can be used to filter the data to the desired record.

DoCmd.OpenReport "report", , ,"Keyfield = " & Me.keyfield
 
Back
Top