Running reports in Access 2007

R

Rob W

Greetings,

I initially used the button wizard to assign a macro to run my access report
on my run report form.
Within my report I had a button to allow the user to print the report and
close the report to be returned back to the run report form.

As I wanted to checked if the report was empty or not before running, I
removed the button created by the wizard and manually did one and assigned
the following vba code to it (see below)

However I can now only get my report to OPEN in preview mode, rendering all
button inopertable as you can't access it and have to use access controls to
exit the preview mode. You can see buttons on the report just cant access
them.

How can I get the report to be generated and allow button interactivity?
Hope this makes sense, let me know if I need to clarify more.

Thanks
Rob

Private Sub cmdopenreport_Enter()

On Error GoTo Report_NoData_Error

If IsNull(cboStudentid) Then
MsgBox "Please choose a student Id", vbCritical
cboStudentid.SetFocus
Else
DoCmd.OpenReport "rptStudentClassification", acPreview
'Results in error cant find command RunReport !!!!
' DoCmd.RunReport "rptStudentClassification"
End If

Report_NoData_Exit:
Exit Sub

Report_NoData_Error:
If Err.Number = 2501 Then 'the report was cancelled
Exit Sub
Else
MsgBox Err.Number & " - " & Err.Description
Resume Report_NoData_Exit
End If


End Sub
 
A

Allen Browne

If you were able to click the buttons on your report, you must have been in
Report view, not Print Preview.

Try:
DoCmd.OpenReport "rptStudentClassification", acViewReport
 

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