473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Computer hangs after switching report to Print Preview

204 128KB
Hello everybody, Happy New Year.
My new year will be happier if I can figure out why my database hangs ...

I have a report which opens in Report view, but with Screen-only buttons on it to Print, Print Preview or Close. The Print Preview button calls an on-click event procedure as follows:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdPreviewButton_Click()
  2. Dim strReportName As String
  3. strReportName = Me.Name
  4. DoCmd.OpenReport strReportName, acViewPreview
  5. End Sub
  6.  
It all works fine.

But sometimes, instead of calling the report from the Switchboard, I need to call it in VBA with some OpenArgs from the on-click event of another form. When I do, it opens in Report view OK, but when I press the PrintPreview button it switches to print preview and then hangs. By "hangs", I mean that I can scroll up and down the report by mouse or keys, but nothing else I try in the Access window will work. I can't close the report, I can't switch to another tab in Access, I can't go to the navigation pane, I can't go to the code. But I can switch to another window (i.e. another application) and back, and then it's all alive again.

Stepping through the code, when I click the PrintPreview button it executes the OnClose routine, then the OnOpen and OnLoad and gets to the End Sub in line 5 of the above code, then goes nowhere.

Another clue: If I put a MsgBox between lines 4 and 5, the message is displayed ... and the system doesn't hang. Everything works fine. But I don't want a MsgBox there. So I tried replacing it with a DoEvents, but that was no good - it still hangs.

Another clue: If in the calling VBA I call it in PrintPreview directly, that works OK also.

Anyone got any ideas?
Dec 29 '19 #1
5 1701
NeoPa
32,556 Expert Mod 16PB
That seems a bit of a weird approach. Either you want to open it again from scratch, or you want to convert it to PrintPreview with existing settings.

If you want the former then you should get it to close itself first, before going on to open it again as per your requirements. This may work from within the code of the object itself or you may need to set a timer somewhere to trigger it once the current Report object has closed.

If you want the latter then you need to switch the mode rather than opening it again from scratch.
Jan 1 '20 #2
Petrol
204 128KB
Well it's definitely the latter that I want, but how do I switch mode?
I did find Report.CurrentView, but that's read-only (despite the note on docs.microsoft.com that it's read-write :( ). And a google search hasn't turned up any way to switch views without re-opening the report - only the other way round.
Jan 1 '20 #3
NeoPa
32,556 Expert Mod 16PB
Ooops!

It seems I leapt before I looked there. I had assumed that would be an obvious facility to be provided within Access but when I look ... No such capability :-( At least none that I could find either.

In that case I would simply ask if your design is quite what you are looking for? Why have menu capability on a Report? Why not have a Form object that allows the operator to decide what it is that they want and separately, a Report object that displays the data you want reported.

I must admit I always struggled to see why it made sense to provide interactive capability on Reports. The only effect I would anticipate is to allow less experienced developers to get themselves deeper into the mess before realising what they're doing doesn't make sense. Sure it can save having to consider the design too carefully. For me though, that's never a good aim.

Sorry I misled you earlier. That was careless of me.
Jan 2 '20 #4
Petrol
204 128KB
Well it seems an eminently sensible thing to want to do. Often the user will just want to look at the report on screen, and Report view is by far the most convenient way to do so - Print Preview opens in page-at-a-time view and has to be clicked to make it readable, and then the PgDn key (or even Ctl+PgDn) won't go to the next page, you have to muck around with tiny pagination buttons at the bottom of the screen ... Report view is much easier to get along with, especially if the information occupies more than one page and you don't need a printout.

But occasionally the user does need a printout, to take to a meeting or something. So it's nice to be able to flip across to Print Preview to see how it will look. Why shouldn't it be possible? In fact, the fact that an expert like you "had assumed that would be an obvious facility to be provided within Access" is reason enough to expect it would be OK.

And Microsoft definitely understands the need in principle to have interactive reports - see, for example, https://support.office.com/en-us/art...f-5cf324c2c3bd.

But we're getting away from the point. As I said in the OP, the Print Preview button works beautifully if the report is invoked from the main switchboard. Why does it hang the computer when called through VBA, and how can I get around it?
Jan 2 '20 #5
NeoPa
32,556 Expert Mod 16PB
Let me start by saying that, without the ability to switch modes being provided I don't see anything that I can help you with.

Now that's clear, let me clarify what I was actually saying, as you seem to have misinterpreted my earlier comment :
I see the idea of switching between live modes (anything that isn't a development mode.) as an obvious ability that's needed. If ever there are multiple modes that a user would use then the ability to switch between them seems an obvious requirement.

Does that mean I have, or would, ever suggest that a report should have an interactive mode? No. I neither said it nor implied it. To infer otherwise is simply wrong.

A view that enables you to navigate it more easily? Sure. If you like that I see no reason why you shouldn't have it. Having Command Buttons and/or other interactive Controls on a report? No. Never been a fan. It simply confuses people. From my PoV it's quite illogical.

I'm sorry I was unable to help, but my comments were neither illogical nor inconsistent. You may perfectly well choose to disagree with them, but please don't try to make it sound like I said anything other than what I actually said.
Jan 6 '20 #6

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

Similar topics

1
by: Devesh Aggarwal | last post by:
I developed reports in Crytsal Reports 9.0 in landscape mode. When i print the same from crystal reports it prints perfectly in Landscape even if the printer setting is set to potrait by default. ...
7
by: Pat | last post by:
I would like to send the Print Preview of a MS Access form to a Snapshot file. The form contains an OLE graph. BACKGROUND A snapshot of a report is possible. If I could I would use a report to...
2
by: Dean Slindee | last post by:
Anybody written code in VB.NET to: 1) show a print preview window of reports already written and stored in an Access 2002 database; or 2) execute the print of a report stored in an Access 2002...
2
by: Brad Pears | last post by:
I have a vb.net 2005 application and am using the print preview screen. This screen has a printer icon on it that the user can use to print the document currently being viewed. It uses the default...
4
n8kindt
by: n8kindt | last post by:
i have a thread posted elsewhere but it got long and messy. this is all that needs to be seen: http://i3.photobucket.com/albums/y72/n8kindt/verticalerror2-1.jpg the report looks great until i...
4
by: scubasteve | last post by:
I've developed a product pricing application for a client in AC2007. They enter all the data on the one main form, then click a button to open a printable report in Print Preview. My problem...
3
by: KingKen | last post by:
I would like to create an active hyperlink in my report that would allow me to open a form. Is there a way to accomplish this?
5
by: Yousaf Shah | last post by:
Hello everybody. I am developing database for my patients. I have almost the needed stuff but now struck at report level. At the end of all required data entry, I want to give prescription to my...
14
by: Pookaroo85 | last post by:
I have a report that pulls data correctly, but within the report is a subreport that is not showing up. If I open the report in layout view, the subrepot information is there but it doesn't print. ...
16
by: Petrol | last post by:
I have a report which I open in Report View, but I want the user to be able to switch to Print Preview. So I have a "Preview" command button with a very simple event procedure:Private Sub...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.