Set focus on Report (1 Viewer)

Tanya

Access Novice
Local time
Yesterday, 18:53
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
 

RainLover

VIP From a land downunder
Local time
Today, 11:53
Joined
Jan 5, 2009
Messages
5,041
Tanya

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

You should not have a problem with that method.
 

Tanya

Access Novice
Local time
Yesterday, 18:53
Joined
Sep 7, 2008
Messages
165
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
 

Rich

Registered User.
Local time
Today, 02:53
Joined
Aug 26, 2008
Messages
2,898
Toggle the forms .Visible property, ie.MyForm.Visible = False/True
 

RainLover

VIP From a land downunder
Local time
Today, 11:53
Joined
Jan 5, 2009
Messages
5,041
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:

Tanya

Access Novice
Local time
Yesterday, 18:53
Joined
Sep 7, 2008
Messages
165
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
 

Tanya

Access Novice
Local time
Yesterday, 18:53
Joined
Sep 7, 2008
Messages
165
The form is modal and is dependant on ClassID
 

RainLover

VIP From a land downunder
Local time
Today, 11:53
Joined
Jan 5, 2009
Messages
5,041
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.
 

Mike375

Registered User.
Local time
Today, 11:53
Joined
Aug 28, 2008
Messages
2,548
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.
 

Tanya

Access Novice
Local time
Yesterday, 18:53
Joined
Sep 7, 2008
Messages
165
Hi RainLover
It worked wonderfully. I can live with the form opening maximized!
Thank you very much.
Regards
Tanya
 

Tanya

Access Novice
Local time
Yesterday, 18:53
Joined
Sep 7, 2008
Messages
165
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
 

RainLover

VIP From a land downunder
Local time
Today, 11:53
Joined
Jan 5, 2009
Messages
5,041
Tanya

Try this, it may help with your sizing.

Private Sub Report_Open(Cancel As Integer)
DoCmd.Restore
End Sub
 

RainLover

VIP From a land downunder
Local time
Today, 11:53
Joined
Jan 5, 2009
Messages
5,041
Well if you can live with it so can I.

Regards
 

Mike375

Registered User.
Local time
Today, 11:53
Joined
Aug 28, 2008
Messages
2,548
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.
 

Rich

Registered User.
Local time
Today, 02:53
Joined
Aug 26, 2008
Messages
2,898
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

Top Bottom