Runtime error 2501

P

Paul3rd

Hello,
I have a form "OTradeEvaluations" that opens with
the code:
Private Sub OpnNTrade_Click()
On Error GoTo Err_OpnNTrade_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "NTradeEvaluations"
'Open form at new, blank record (as FormAdd).
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd


Exit_OpnNTrade_Click:
Exit Sub

Err_OpnNTrade_Click:
MsgBox Err.Description
Resume Exit_OpnNTrade_Click

End Sub

A Print button on the form has the following code:
Private Sub PBNTE_Click()

Dim stDocName As String
Dim MyForm As Form

stDocName = "NTradeEvaluations"
Set MyForm = Screen.ActiveForm

DoCmd.SelectObject acForm, "NTradeEvaluations", True
Forms("NTradeEvaluations").Printer.Orientation = acPRORLandscape
DoCmd.PrintOut acSelection, 1, 1, acMedium, 1, False
DoCmd.SelectObject acForm, "NTradeEvaluations", False

Exit_PBNTE_Click:
Exit Sub

End Sub


When the print button is pressed, I get a "Runtime Error 2501"
PrintOut was cancelled.
The debugger shows the problem to be in the line:
DoCmd.PrintOut acSelection,1,1 acMedium,1,False
Is there a way to print out this blank form?
Thanks in advance,
Paul
 
K

Klatuu

You are getting that error because there is no data in the form. The same
will happen for a report if there are no records in the report's recordset.
 
P

Paul3rd

Thanks for the reply,
I'll just make a copy w/no control source and try to print that.
Paul
 

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