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

Report Opening

100+
P: 173
hi,

i have a form that has two buttons......................

one button opens a form with a combobox.............. this combobox has a list of usernames(from the table)........ When selecting a username, it brings up a report with the users details.

the other button opens a report of all users...........

THE PROBLEM that i have is... when it opens the report whether from the combobox or directly from a button..... the report is displayed behind the all the forms.. i have to close down the forms to view the report...........y is that?

and also if i select from the combobox, i must close down the combobox screen to actually view or access the report????:(
Dec 11 '06 #1
Share this Question
Share on Google+
12 Replies


NeoPa
Expert Mod 15k+
P: 31,615
Try adding this line of code to your report's OnOpen event procedure :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.SelectObject(ObjectType:=acReport, ObjectName:=Me.Name)
Dec 11 '06 #2

NeoPa
Expert Mod 15k+
P: 31,615
If that doesn't help you must have some code in your project (running after the report is displayed) that selects the form again and brings it to the front.
Dec 11 '06 #3

100+
P: 173
can you explain that code to me?

im using the following code for my combobox:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "Report2", acPreview, "", "[userID]=[Forms]![comboreport]![Combo0]"
Dec 11 '06 #4

NeoPa
Expert Mod 15k+
P: 31,615
Not much to explain really.
It selects the report object and brings it to the front of the window.
Dec 11 '06 #5

MMcCarthy
Expert Mod 10K+
P: 14,534
At a guess I would say you have the Modal property on your forms set to yes.

Mary
Dec 11 '06 #6

100+
P: 173
my pop up and modal are all set to NO....


Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.SelectObject(ObjectType:=acReport, ObjectName:=Me.Name) 
In ObjectName:=Me.Name, do i change Me.Name to my report name?

my report is called Report2
Dec 12 '06 #7

NeoPa
Expert Mod 15k+
P: 31,615
my pop up and modal are all set to NO....


Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.SelectObject(ObjectType:=acReport, ObjectName:=Me.Name) 
In ObjectName:=Me.Name, do i change Me.Name to my report name?

my report is called Report2
No, that's exactly as it needs to be.
I'm not hopeful it will work, but it can't do any harm testing.
Me.Name means get the name for the object I'm in (code-wise).
Dec 12 '06 #8

100+
P: 173
sorry it didnt work im getting the following error message:

Run-time error '2530':

The SelectObject method can't be used on a report that is currently printing
Dec 12 '06 #9

100+
P: 173
this is my last problem..................................

i need help
Dec 12 '06 #10

NeoPa
Expert Mod 15k+
P: 31,615
this is my last problem..................................

i need help
See post #3 Beany. I suspect this is where we've got to on this.
We cannot tell you what you may or may not have in your current code.
This is something you'll have to find for yourself I'm afraid.
Dec 12 '06 #11

twinnyfo
Expert Mod 2.5K+
P: 3,331
Beany,

I used that same code on reports for months and then Access all of a sudden decided to start giving me the same error you described. Here is the solution:

From the parent form that calls your report:

Expand|Select|Wrap|Line Numbers
  1.     DoCmd.OpenReport "ReportName", acViewPreview
  2.     DoCmd.SelectObject acReport, "ReportName"
For some reason, this allows the report to complete its opening procedures and then allows you to select it. It should come to the front (if all your other forms' modal and popup properties are set to no.

Even if those forms are set to modal, you can add a few lines of code to your form to set modal to false, then open the report. Then, in the OnClose event of your report, reset the modal porperty on your forms to true.

Good luck!
Nov 16 '11 #12

NeoPa
Expert Mod 15k+
P: 31,615
Beany:
Run-time error '2530':

The SelectObject method can't be used on a report that is currently printing
Wow. This thread is from my first month of involvement with Bytes (or TheScripts as it was called then).

@Twinnyfo
If you look back through the thread you'll see that your (very sensible) suggestion has already been posted, but to no avail (See quoted post for reported results of that).

Now I go through it again all this time later, I notice that this error message indicates that the report is not being opened as one would suspect (and as Twinnyfo had it) with the acViewPreview parameter value, but clearly it must have used the default of acNormal instead, which causes the report to print directly to the printer instead of to show on the screen. This is the cause of the problem, but as the OP (Beany) posted the question so poorly (without including any hint of their code) that never came to light before.
Nov 16 '11 #13

Post your reply

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