error message when previewing report from a command button

P

Paul James

I've got a report that I'm trying to preview from a command button in a
form. However, when I click the button, I get the following error message:

"The expression On Click you entered as the event property setting produced
the following error: A problem occurred while Microsoft Access was
communicating with the OLE server or ActiveX Control.
* The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
* There may have been an error evaluating the function, event or macro."

I can open the report directly by double clicking on it in the database
window, and I'm able to open other reports with command buttons on forms, so
I don't think I'm missing a necessary Object Library. For some reason,
however, I get this error message opening this particular report from
command button. I've also recreated the button with the Command button
Wizard in form design view, and still get the error message with the new
button.

The click event for the command button is as follows:

Private Sub cmdPreviewDenialReport_Click()
On Error GoTo Err_cmdPreviewDenialReport_Click

Dim stDocName As String

stDocName = "rptDenialReport"
DoCmd.OpenReport stDocName, acPreview

Exit_cmdPreviewDenialReport_Click:
Exit Sub

Err_cmdPreviewDenialReport_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewDenialReport_Click

End Sub

Can anyone tell me how to overcome this problem?

Thanks in advance,

Paul
 
P

Paul James

The preceding message didn't provide any information in response to my
question. Instead it included a link to a fee-based web site. So I'll
repeat my original question in the hopes that someone may provide a response
in this newsgroup:

I've got a report that I'm trying to preview from a command button in a
form. However, when I click the button, I get the following error message:

"The expression On Click you entered as the event property setting produced
the following error: A problem occurred while Microsoft Access was
communicating with the OLE server or ActiveX Control.
* The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
* There may have been an error evaluating the function, event or macro."

I can open the report directly by double clicking on it in the database
window, and I'm able to open other reports with command buttons on forms, so
I don't think I'm missing a necessary Object Library. For some reason,
however, I get this error message opening this particular report from
command button. I've also recreated the button with the Command button
Wizard in form design view, and still get the error message with the new
button.

The click event for the command button is as follows:

Private Sub cmdPreviewDenialReport_Click()
On Error GoTo Err_cmdPreviewDenialReport_Click

Dim stDocName As String

stDocName = "rptDenialReport"
DoCmd.OpenReport stDocName, acPreview

Exit_cmdPreviewDenialReport_Click:
Exit Sub

Err_cmdPreviewDenialReport_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewDenialReport_Click

End Sub

Can anyone tell me how to overcome this problem?

Thanks in advance,

Paul
 
M

Marshall Barton

Paul said:
I've got a report that I'm trying to preview from a command button in a
form. However, when I click the button, I get the following error message:

"The expression On Click you entered as the event property setting produced
the following error: A problem occurred while Microsoft Access was
communicating with the OLE server or ActiveX Control.
* The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
* There may have been an error evaluating the function, event or macro."

I can open the report directly by double clicking on it in the database
window, and I'm able to open other reports with command buttons on forms, so
I don't think I'm missing a necessary Object Library. For some reason,
however, I get this error message opening this particular report from
command button. I've also recreated the button with the Command button
Wizard in form design view, and still get the error message with the new
button.

The click event for the command button is as follows:

Private Sub cmdPreviewDenialReport_Click()
On Error GoTo Err_cmdPreviewDenialReport_Click

Dim stDocName As String

stDocName = "rptDenialReport"
DoCmd.OpenReport stDocName, acPreview

Exit_cmdPreviewDenialReport_Click:
Exit Sub

Err_cmdPreviewDenialReport_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewDenialReport_Click

End Sub


In my limited experience with this error, it's either
because I had something funky in the OnClick property
instead of [Event Procedure] or because there was a compile
error in the form's module. Try compiling your project to
make sure there's nothing wrong in some part of the code.
 
M

Marshall Barton

Paul said:
Well, the project compiled, and now the problem has disappeared.

Thanks, Marsh


You're welcome, I guess.

That's a little wierd, I would have expected it to find some
kind of error, but if it works, let's not get too confused
about it ;-\
 

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