Discussion Locked

DoCmd.OpenReport

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am using the DoCmd.OpenReport command as illustrated below:
strSSN = Me.SSN
stDocName = "PerfPlan"

strSQL = "SSN = '" & strSSN & "'"
DoCmd.OpenReport stDocName, acNormal, , "SSN = '" & strSSN & "'"

But I get the following error: "The command or action 'OpenReport' isn't available now."

If I change the acNormal to acPreview the report displays OK and I can print from there.

How can I get the report(s) to print without having to preview them first.

Thanks,
Stan

3 replies

by sl-campbell

First, I believe the acNormal and acPreview constants are for forms. For reports use acViewNormal and acViewPreview.

Second, is Database window is hidden at the time you call the OpenReport?
If so then see the work-around at:
http://support.microsoft.com/support/kb/articles/Q244/6/95.ASP

Also, if you want to print out, you will not be able to use certain features like print range, quality or number of copies.

MS suggest to do the following:

Application.Echo False
DoCmd.OpenReport stDocName, acViewPreview
DoCmd.SelectObject acReport,stDocName,False
DoCmd.PrintOut acPages, 1, 1, , 2
DoCmd.Close acReport, stDocName, acSaveNo
Application.Echo True

This discussion is closed to new replies.