By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

Docmd.OpenReport or DocmdRunReport (Available in access 2007 ??)

100+
P: 108
Greetings,

I originally used a button on a from created via the button wizard (access 2007) to run my report which was based on a query.

Since I wanted to add some validation I removed the button and added my own
code (as below):-

However the open report is just a preview and the user cant exit the preview
screen without directly using access controls.

I cant use the DoCmd.RunReport method :-(

I want to create report output and then use buttons on the report output
allowing for more user navigation and functions.

How do I run reports and allow the screen to include the actual report
output with workable buttons etc.., as per available in the macros assigned using button wizard ?

Hope this makes sense.

Thanks Rob

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdopenreport_Enter()
  2.  
  3. On Error GoTo Report_NoData_Error
  4.  
  5. If IsNull(cboStudentid) Then
  6.         MsgBox "Please choose a student Id", vbCritical
  7.         cboStudentid.SetFocus
  8. Else
  9.     DoCmd.OpenReport "rptStudentClassification", acViewPreview
  10.    ' DoCmd.RunReport "rptStudentClassification"
  11. End If
  12.  
  13. Report_NoData_Exit:
  14. Exit Sub
  15.  
  16. Report_NoData_Error:
  17. If Err.Number = 2501 Then 'the report was cancelled
  18.     Exit Sub
  19. Else
  20.     MsgBox Err.Number & " - " & Err.Description
  21.     Resume Report_NoData_Exit
  22. End If
  23.  
  24.  
  25. End Sub 
Feb 20 '08 #1
Share this Question
Share on Google+
4 Replies


100+
P: 108
I should add using DoCmd.RunReport "rptStudentClassification" gave the message

"Compile Error: Method or data member not found" though this code works:-

DoCmd.OpenReport "rptStudentClassification", acViewPreview

Indicating the report is fine.

Thanks
Rob
Feb 20 '08 #2

100+
P: 108
Further clarification of problem:-

In access 2007 using the button wizard you can assign a report to run it
upon click event (macro).

Rather than seeing the preview window with magnifying glass you see the
report output.
Within the report layout you can add buttons to it and assign code.

The buttons on my report can be seen using openreport, but as its in preview
mode they cant be clicked.
Feb 20 '08 #3

NeoPa
Expert Mod 15k+
P: 31,266
Let's start with a couple of simple things :
  1. DoCmd has no .RunReport method. It DOES have .RunCommand, .RunMacro and .RunSQL methods. It also has a .OpenReport method.
  2. Reports don't have clickable Command Buttons. They can exist, but are not clickable (Why? I don't know).
Perhaps #2 is not so simple then I suppose.
I can only guess that they are there as Reports and Forms share a lot of similarities. Maybe someone else knows better.
Feb 20 '08 #4

NeoPa
Expert Mod 15k+
P: 31,266
It looks like what you're looking for is actually to run the selecting etc from a form before opening the Report. Example Filtering on a Form gives some help with this concept. It works mainly with Forms but the concepts are the same.
Feb 20 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.