Print form current record only with subform

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
 
M

Marshall Barton

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top