Print Button on Report

kitty77

Registered User.
Local time
Today, 02:13
Joined
May 27, 2019
Messages
715
I put a print button on a report. When I click it I get the following error...

The command or action "PrintSelection isn't available now.

My code is

Private Sub Command78_Click()
On Error GoTo Command163_Click_Err
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPrintSelection

Command163_Click_Exit:
Exit Sub
Command163_Click_Err:
MsgBox Error$
Resume Command163_Click_Exit
End Sub

Does anyone know what this error is?

Thanks...
 
The command works with form, not report.
 
an alternative.

copy/paste your report.
on the copy, remove the button and the code.

on the original, if you have any autonumber/pk field there, add code to its Click event:
Code:
dim lngID as long

private sub ID_click()
lngID = me.ID
end sub

on your code:
Code:
Private Sub Command78_Click()
On Error GoTo Command163_Click_Err
	docmd.openreport "the name of copy", acNormal, , "[id]=" & lngID
Command163_Click_Exit:
	Exit Sub
Command163_Click_Err:
	MsgBox Error$
	Resume Command163_Click_Exit
End Sub
 

Users who are viewing this thread

Back
Top Bottom