Set focus on Report

Tanya

Access Novice
Local time
Today, 01:04
Joined
Sep 7, 2008
Messages
165
Hi my report opens fine except that I can't access it without closing the form which has the following code to open the report: My question is, is there a way to open the report and maintain a focus on the report until you close it?

Private Sub CmdPreviewAllStudents_Click()
On Error GoTo Err_CmdPreviewAllStudents_Click
Dim stDocName As String
stDocName = "rptExcursionStudentRecord"
DoCmd.OpenReport stDocName, acPreview, , , acWindowNormal

Exit_CmdPreviewAllStudents_Click:
Exit Sub
Err_CmdPreviewAllStudents_Click:
MsgBox Err.Description
Resume Exit_CmdPreviewAllStudents_Click

End Sub

Kind regards
Tanya
 
Tanya

Just use the wizard to create a command button that will open the report.

You should not have a problem with that method.
 
Hi Ned
I have already tried that, I think the problem is however on reflection that the report is looking at a query with a where clause directed at the form. i.e. it is looking for the ExcursionID to base the report on.
Tanya
 
Toggle the forms .Visible property, ie.MyForm.Visible = False/True
 
Hi Ned
I have already tried that
But that is not what your code says.

You wrote something different.

Edit

What command do you use to open the Form.

Is it Modal or Popup??
 
Last edited:
Hi, I ended up simply getting the report to print. But interested in how to toggle the forms to view True and False. Could you please give me some direction on this.
Thanks
Tanya
 
The form is modal and is dependant on ClassID
 
Hi, I ended up simply getting the report to print. But interested in how to toggle the forms to view True and False. Could you please give me some direction on this.
Thanks
Tanya
Sorry I don't know what you mean by this.

I suggest that you get rid of the Modal.
 
Have you used SelectObject. That is a macro action but convert to code if you want code.

The report would be the object.

If you have something being done that depends on the Report being the active one then use SeectObject before the other actiions.
 
Hi RainLover
It worked wonderfully. I can live with the form opening maximized!
Thank you very much.
Regards
Tanya
 
Hi Mike,
Not sure what you are suggesting here by

Select object before before other actions?

The only action I was looking for was to preview a report, What actions would you suggest to follow?

cheers
Tanya
 
Tanya

Try this, it may help with your sizing.

Private Sub Report_Open(Cancel As Integer)
DoCmd.Restore
End Sub
 
Well if you can live with it so can I.

Regards
 
Tanya,

I rarely use Reports. SelectObject makes the selected object active. Used a lot when different forms are open.

I imagine with a Report you would have an action to open the report in PrintView and the following action line would be SelectObject.
 
Hi, I ended up simply getting the report to print. But interested in how to toggle the forms to view True and False. Could you please give me some direction on this.
Thanks
Tanya


Private Sub CmdPreviewAllStudents_Click()
On Error GoTo Err_CmdPreviewAllStudents_Click
Dim stDocName As String
stDocName = "rptExcursionStudentRecord"
DoCmd.OpenReport stDocName, acPreview, , , acWindowNormal
Me.MyForm.Visible=False

Etc.................


In the unload event of the Report, Forms!YourForm.Visible = True
 

Users who are viewing this thread

Back
Top Bottom