MSAccess Lose Focus on Print Preview (1 Viewer)

yunnipembokat

Registered User
Joined
Jul 27, 2011
Messages
10
I have a form that has field and button to query a report.
User fill in the field and hit the button to view the report.

I use this command to open the report.
DoCmd.OpenReport sReportType, acViewReport, , sQuery, acWindowNormal, sQuery

On the report itself it has a print preview button, which I use a macro to code it.
Action : OpenReport
Report Name : Import Rpt
View : Print Preview
Filter Name & Where Condition : Left Empty
Window Mode : Normal

It could trigger to open the print preview view of the report. But MSAccess has lost the focus. So user must go somewhere else then go back to MSAccess to have control to the mouse.

I am using MSAccess 2007 SP 2 with Windows 7 OS.
Hope somebody could help me out here.



Regards
 

yunnipembokat

Registered User
Joined
Jul 27, 2011
Messages
10
Strange issue ... starts to frustate me
 

missinglinq

AWF VIP
Joined
Jun 20, 2003
Messages
6,330
Not to be unkind, but rather to be honest, your post and code makes little sense, which I suspect is why over 60 people have read it over the past three days and no one has responded until a a few hours ago!

You're using code to open a Report, in acViewReport mode, which is the same as Print Preview, then you say you have a Print Preview button on that Report which you're using, via a Macro, to open yet another Report in Print Preview?

And your posted code
Code:
DoCmd.OpenReport sReportType, acViewReport, , sQuery, acWindowNormal, sQuery
uses the same Variable, sQuery for both the Where clause and the OpenArgs?

"Strange issue" is a huge understatement, and I seriously doubt that anyone else is "faceing the same issue here!"

There are people here who would like to help you, but I think you'll have to explain to us, in plain English, exactly what you're attempting to do here.

Linq ;0)>
 

yunnipembokat

Registered User
Joined
Jul 27, 2011
Messages
10
Not to be unkind, but rather to be honest, your post and code makes little sense, which I suspect is why over 60 people have read it over the past three days and no one has responded until a a few hours ago!

You're using code to open a Report, in acViewReport mode, which is the same as Print Preview, then you say you have a Print Preview button on that Report which you're using, via a Macro, to open yet another Report in Print Preview?

And your posted code
Code:
DoCmd.OpenReport sReportType, acViewReport, , sQuery, acWindowNormal, sQuery
uses the same Variable, sQuery for both the Where clause and the OpenArgs?

"Strange issue" is a huge understatement, and I seriously doubt that anyone else is "faceing the same issue here!"

There are people here who would like to help you, but I think you'll have to explain to us, in plain English, exactly what you're attempting to do here.

Linq ;0)>
Hi,

Sorry if my question was unclear. The essential question is MSAccess lose focus when print preview a report when I open the report using the code. And yes this is the same report. I need to do this since the user of my application is very basic.

When the report opens using
Code:
DoCmd.OpenReport sReportType, acViewReport, , sQuery, acWindowNormal, sQuery
, the users can not figure a way to print out the report. Thats why within this report I must put a button that open Print Preview version of the report. The trick is I put this print preview button outside the pint area. And I use macro to trigger the Print Preview.

Ok let me elaborate more, if needed.

I have 10 individual reports, which are reports that show progress from import, warehouse, process, and finally arrives at export. Each process has 1 report. And total are 10 reports.

At the end, management wants the "conclusion" report, which is the combination of all the 10 reports in 1 report. So I duplicate the report for those 10 reports. For example Import Report become X_Import_Report and so on. And put all these X marked reports to 1 parent report.

This is the reason I put sQuery in both filter and OpenArgs.
sQuery in filter is for the individual report. And sQuery in OpenArgs is for the sub-report in parent report.

I use this code on the parent report, to pass the filter to each individual report.
Code:
Private Sub Report_Load()
        
        With Me.X_Import_Report.Report
            .Filter = Me.OpenArgs
            .FilterOn = True
        End With
Hope this clears my question



Regards
 

GinaWhipp

AWF VIP
Joined
Jun 21, 2011
Messages
5,578
I still don't get... The report once it opens should maintain the focus. What version of Access? And is there any other code attached to this report?
 

yunnipembokat

Registered User
Joined
Jul 27, 2011
Messages
10
Hi Ginna,

I'm using Access 2007 SP 2 on Windows 7.

Yes, once the report opens via the code it has the focus. However, when I trigger the print preview mode via a button (executed from macro expression) Access lost its focus. I must click somewhere else outside Access then get back to it.

If you really want to help. I could send you my application so you can take a look.


Regards
 

gemma-the-husky

Super Moderator
Staff member
Joined
Sep 12, 2006
Messages
13,873
surely in print preview mode - you can either right-click the report, and print that way - or use file/print to get at the same functionality.
 

GinaWhipp

AWF VIP
Joined
Jun 21, 2011
Messages
5,578
Ummm, okay kind of put off by that... "If you really want to help..." Anyone who answers REALLY wants to help or they would have skipped by the question...

You can upload the databse here and I will look at it. And just so you don't feel like I'm ignoring you I really do have a day job!
 

yunnipembokat

Registered User
Joined
Jul 27, 2011
Messages
10
@gemma-the-husky
Sure we can do it that way. But as I said earlier. This app is for basic users. So it is easier for users if we prepare a button for them to print preview it.

@GinaWhipp
Thanks a lot for your generosity spare your time and effort to look at it. Don't worry I won't take it that way :)

Here is the database...

Steps to reproduce the issue
1. Open the accdb
2. Redirected to "Interface" form
3. Look at third section i.e. Report
4. Then look at "Report by Job"
5. Choose the first Job ID i.e. 1106JSClientA
6. Choose report type "Import Report"
7. Import Report will open, and at the bottom-right there are 2 buttons. Print Preview and Exit buttons.
8. Try to click at Print Preview button then MSAccess loose the focus.
 

Attachments

Last edited:

GinaWhipp

AWF VIP
Joined
Jun 21, 2011
Messages
5,578
Not sure what you mean when you say Access loses focus. The report opens and I see it. What part do mean loses focus?
 

yunnipembokat

Registered User
Joined
Jul 27, 2011
Messages
10
Not sure what you mean when you say Access loses focus. The report opens and I see it. What part do mean loses focus?
Hi Gina, thanks for taking a look at my app.
At step 8, when I click "Print Preview" button. MSAccess lose focus. Yes, the print preview displayed but I cannot click anything on MSAccess, I must click somewhere else outside MSAccess and get back to MSAccess.

You did not face this issue?
 

GinaWhipp

AWF VIP
Joined
Jun 21, 2011
Messages
5,578
Okay, I got it now... I waited and the focus came back. So by the time I checked all was well. I can't see why that happens so will have to look into it. I don't put buttons on reports so never faced that issue.
 

GinaWhipp

AWF VIP
Joined
Jun 21, 2011
Messages
5,578
You know something else I have never tried to do which might be creting the problem. Technically the report is already open to print and you have a button that switches the same report to print preview. Why? Why not just put a print button there?
 

GinaWhipp

AWF VIP
Joined
Jun 21, 2011
Messages
5,578
And as long as I'm reading, this...

Code:
DoCmd.OpenReport sReportType, acViewPreview, , sQuery, acWindowNormal, sQuery
...can be changed to...

Code:
DoCmd.OpenReport sReportType, acViewPreview, , sQuery
 

yunnipembokat

Registered User
Joined
Jul 27, 2011
Messages
10
Okay, I got it now... I waited and the focus came back. So by the time I checked all was well. I can't see why that happens so will have to look into it. I don't put buttons on reports so never faced that issue.
I wait for like 5 mins and focus never get back :(

Yes normally we dont put buttons on report. But the users request it because they are very computer basic users.

Hope somebody could figure it out.
 

yunnipembokat

Registered User
Joined
Jul 27, 2011
Messages
10
You know something else I have never tried to do which might be creting the problem. Technically the report is already open to print and you have a button that switches the same report to print preview. Why? Why not just put a print button there?
Hmm pretty good idea. Never cross my mind...Not bad solution if this technical issue cant be fixed. Thanks for the input.

As you said, the report already open (in normal view), why switching to print preview mode make MSAccess lose focus?
 

GinaWhipp

AWF VIP
Joined
Jun 21, 2011
Messages
5,578
Yeah, still working on why that happens... been playing with the code but nothing is helping. I'm sure there's a logical reason, just wish Access would share it!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom