The strangest thing happens when I want to open a report using vba script

George_E

Registered User.
Local time
Today, 20:54
Joined
Sep 28, 2009
Messages
32
Hey guys

I have 2 radio buttons and a button on a form. If the user clicks on one radio button and clicks on the form's button it opens one report and when the user clicks on the 2nd radio button and clicks on the form's button, it opens the second report.

However what really does happen is that, whatever radio button I click on, and click on the form's button, instead of opening the particular report I wish for, it appears as though its trying to print and it also opens Microsoft Office One Note and a message appears saying "Files from other programs cannot be opened in onenote, select a onenote file.

Below is the code I am using:

Private Sub Command10_Click()
Select Case Me!Frame19
Case 1
DoCmd.OpenReport "rptIssSummary"
Case 2
DoCmd.OpenReport "rptAssSummary"
Case Else
'do nothing
End Select
End Sub

Im really baffled with this one

Thanks for your time guys

George
 
If you wish to open your reports in "Preview" mode then you need to change both of the "DoCmd.OpenReport "rptIssSummary"" statements to include the "acPreview" parameter, like:

DoCmd.OpenReport "rptIssSummary", acPreview
 
If you look at VBA help on OpenReport, there is an argument to determine whether the report is printed or previewed. The default when it is not specified is to print to the default printer.
 
I have attached a copy of the database if that helps
 
Hey guys, thankyou for your quick responses, you are both right, I have changed the code and it now opens the reports I want, not print them. Here is the code after the ammendments
Private Sub Command10_Click()
Select Case Me!Frame19
Case 1
DoCmd.OpenReport "rptIssSummary", acViewReport
Case 2
DoCmd.OpenReport "rptAssSummary", acViewReport
Case Else
'do nothing
End Select
End Sub
 
Hello guys, thankyou for your quick responses, you are both correct and have helped me to solve my problem. I needed that additional code. Here is the code that works now:

Private Sub Command10_Click()
Select Case Me!Frame19
Case 1
DoCmd.OpenReport "rptIssSummary", acViewReport
Case 2
DoCmd.OpenReport "rptAssSummary", acViewReport
Case Else
'do nothing
End Select
End Sub


It required teh extra acViewReport at the end.

Thankyou again for your help, I much appreciate it :)

George
 

Users who are viewing this thread

Back
Top Bottom