Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Previewing a Report OVER a Modal Form 2

Status
Not open for further replies.

snayjay

Programmer
Oct 23, 2001
116
US
Just what the subject says. Normally if you use a cmdbutton to Preview a Report... it will work fine if the Form is not Modal. But I have a POPUP Form which is also Modal with a cmdbutton that Previews a Report and the report opens but stays behind the Forms. Is there a simple way to bring it to the front. I tried

Reports!REPORTNAME.setfocus

and that didn't work. I checked FAQS for MODAL form and Previewing Reports and didn't get anything so I thought I'd ask the question.
 
You could set the form's visible property to false after opening the report. In the OnClose event of the report, set the form's visible property back to true.
 
Well actually the form that opens it is a MODAL form ontop of a MODAL Form on top of a MODAL form.

So that would mean I'd have to make all 3 forms invisible and then visible again when the report closes. Which I could do and I will try (thanks for the option) but do you know of another way NOT messing with the other forms? Just curious, if I have to do it this way I will.
 
What version? Starting with xp (2002), the openreport method of the docmd object has a windowmode arguement, where you can pass acDialog, as with forms.

Roy-Vidar
 
Fancy, let me correct myself. The top form where the cmd button is IS NOT modal. But the 2 forms underneath are. I tried your suggestion and it worked partly. It brought the Report to focus fine. But when making the 3 forms visible again on Report_Close, the middle form never was visible. Don't know how that happens. Anyway at that point the program locks up as if the middle form was hidden but still Modal. And I tried varying the order in which I brought them back visible again...still no good.

Roy, I tried acDialog, and unfortunately it didn't do squat either. Didn't bring it to focus and when I did close all the forms to get to the report the Report had lost it's toolbar losing the option to print. When I put it back on acWindowNormal it was fine again. But still wouldn't come to focus.

I tried making the report Popup but that didn't work until I made it Modal. But then when I closed the Modal Report, the other forms weren't accessible...kept getting a ding ding ding....and I could get to the top form (non-modal) but couldn't access the bottom ones, and those have the close buttons on them, so I had to ctrl-alt-del my way out of the program.

For now I guess I'll just print this report. Fortunately this report doesn't necessarily NEED to be previewed. But I have others that have the same problem and therefore if you can think of any other way to fix it...I'd appreciate it.

<additional crap about my program, not necessary reading to answer my question...>

If you are wondering why I wanted Modal form ontop of Modal form, it's because of the forms that go into the taskbar. I didn't want 3-4 forms in the taskbar when all 4 forms are open, Only wanted one and the outermost form accessible. May sound weird but you'ld have to see the program to understand it (maybe). Anyway, doing it this way only leaves one form in the taskbar and traditionally the Access window. But I used a module/Hide Macro I found here to remove that as well. Only leaving me one object in the taskbar for the whole program. When the user clicks on it, it brings up the whole program just the way they left it. Before without the forms being Modal and there were 4 forms in the taskbar. If the user Alt-tabbed out and then came back to the outermost form, they sometimes came back to a Popup Form floating in the middle of the screen. So this was the easiest way to fix it without having to make all the forms Subform of the Mainform.Basically what I have is a Background Menu Form with a self-made menu bar at the top. Users click these buttons to open Popup Forms over the top of the Background Menu Form and sometimes more Popup Forms over that. I hope I haven't lost ya.

Anyway, any help would be greatly appreciated.

~Snay
 
I think some of the anomalities may occur because you're using to much of different manipulation stuff on the objects, where some of it may negate others, with the effect of some of them not working, giving other effects than desired... I'm to concervative to use lot of the fancy stuff, but here's what I often do:

When opening a form from my main menu, I hide the main menu and open the next form with acdialog.

When opening the next form from this form, I do exactly the same, hide the calling form, open the next with acdialog.

When opening a report, I hide the calling form, previewing the report. On close of the different objects, I simply set the calling form to visible.

Most of the versions of hiding the Access window that I've come accross, influences some part of "window" handling within Access (not all properties, methods... works), with the need for additional programming for that (reports!), so I don't bother using them.

I don't bother using the acdialog on reports either, because I need my apps to work on version starting with 2000 .. but you can for instance right click in the report to print. On small tests here, the acDialgo always brings the report to front, so I suppose there's som other code or properties (or database window thingie - if you're using something like mstrmage1768's faq faq705-2562, you did remember to turn it off for the report?) influencing.

As for showing only one program/icon/button in the taskbar, did you try the "Windows in taskbar" option from Tools | Options - view tab.

Roy-Vidar
 
I don't know about the Windows in taskbar option, but I'll check it out.

About the hide Access from the toolbar...yes that's exactly the code I'm using, and I wasn't aware I could shut it off for the reports.

I think I'd really have to show you my program for you to understand why I've done things the way I have. I made a Word Document with screenies on it. If you wanted to see it to see what I'm talking about you can get it at I'll remove the file tomorrow. Anyway, it shows how I've done my forms so you can see why I can't change it to the way you described. It's really a GUI issue. I couldn't think of any other way to achieve the look I wanted. And now because of all that I can't get any Reports to display. Again, any help would be appreciated.

~Snay
 
Oh dear, you mustn't ask an old Access hack about something like this;-)

If the requirements of the system asked for a layout like this, I would probably have bailed out, cause other tools are more suited for such tasks, and I don't know any other tools yet.

Only "hack" that springs to mind, which would circumvent some of this stuff, would be to output the report to snapshot format (or perhaps other formats), with the AutoStart arguement set to true:

[tt]docmd.outputto acoutputreport,"yourrpt",acformatsnp,"c:\rpt.snp",true[/tt]

(or false as AutoStart, then Shell it)

However, if you're relying on dynamic where conditions of the reports, you'd need to enter those into the stored query prior to running the reports, as you can't assign filters directly to the autputto method.

Of course this also works well on my test setup, without "all of them fancy stuff"....

Others may perhaps give better advice than me on this...

Roy-Vidar
 
A simple thing I do to open a report on MODAL form is to set the report MODAL=YES, POPUP=YES and with open command use acDialog. It will open on top of all forms only probelm you won't get any menu/toolbar. You have to use custom shortcut menu.(at least I am not success on setting the tool/menubar)


Zameer Abdulla
Jack of Visual Basic Programming, Master in Dining & Sleeping
Visit Me
 
Roy, I've tried your last suggestion and it's giving me the error:

Run-time error: 2024

The report snapshot was not created because you don't have enough free disk space for temporary work files.

I figured this meant either RAM was low or I needed to clean up my TEMP files. So I ran Nortons Cleansweep on temp files and there were only 23megs to clean up. I have 1 gig ram and this is the only thing running other than normal system crap. I don't know if it's really my computer or if it's the code... here's what I used.

Code:
DoCmd.OutputTo acOutputReport, "BULLETrpt", acFormatSNP, "c:\DESKTOP\BULLET.snp", True

ZmrAbdulla, thanks but you must have missed I tried all that in the beginning. I've got a weird situation where I have a Non-Popup but Modal (Base Form) with a Popup Modal Form on top of that and another Popup form on top of that. I've tried Making them all Modal and all Popup and other variations but to no avail. It still doesn't work properly. Either the Report stays behind 1 of the forms or the middle or outermost form won't show.

I guess for now I'll just close the outermost form and hide the 2nd form open the report and unhide the 2nd form then reopen the 3rd form on the Report_Close(). That hopefully will work, unless you can think of another way. Thanks for helping on this.

~Snay
 
What I said is working & tested.
Form1
PopUp=No
Modal=Yes
BorderStyle=Dialog
'===========================
Form2
PopUp=Yes
Modal=Yes
BorderStyle=Dialog
'============================
Form3
PopUp=Yes
Modal=Yes
BorderStyle=Dialog
'===========================
command to open Report1 from form3
Code:
stDocName = "Report1"
DoCmd.OpenReport stDocName, acPreview, , , acDialog
Report1
PopUp=Yes/No 'no matter any
Modal=Yes/No 'no matter any
BorderStyle= 'no matter any

Code:
Private Sub Report_Close()
DoCmd.Restore
End Sub

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


Zameer Abdulla
Jack of Visual Basic Programming, Master in Dining & Sleeping
Visit Me
 
Zmr, sorry the Forms are Borderstyle-None and this can't be changed. Check out the link I posted above to see the screenies...You'll see why I can't change that. I figured out a way to fix it...although it's long fixit. I have to create a form that looks like the report (for preview purposes) then the user can print the report from there. I shouldn't have to do it this way but because of the way I wanted the forms displayed it's not working any other way that has been suggested. Thanks for the input though.

~Snay
 
Hi, the problem is in your path, unless you have a directory called C:\Desktop

DoCmd.OutputTo acOutputReport, "BULLETrpt", acFormatSNP, "c:\DESKTOP\BULLET.snp", True

Try a temp directory C:\Temp

DoCmd.OutputTo acOutputReport, "BULLETrpt", acFormatSNP, "C:\Temp\BULLET.snp", True

The out of space memory error usually means a path for file naming problem.
 
dRahme, thanks for posting that answer, it works great...and now I can apply it to the other reports as well. I read Roys Post (7 above this) that has the link to the error on it, and I just didn't see that I had the path wrong. I ended up using "..\Desktop\Filename.snp" to put it to my Desktop. Awesome, again this forum saved my butt. I'm trying to finish this database so I can leave my base. I'm stationed here in Korea and I'm supposed to PCS (Permanent Change of Station) on Monday. The program works but there are still some minor inconveniences I'm trying to work out. Again, thanks alot everyone.
~Snay
 
Glad it helped ~Snay and thanks for your service to our country.

dRahme
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top