473,654 Members | 3,076 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DoCmd.OpenRepor t Problem or Limitation?

30 New Member
Maybe I'm missing something or perhaps there's another way to do this. I'm trying to allow the user to preview and print an invoice as they are exiting from the New Sale form. However, the preview opens but closes after a second. Can anyone give me a clue?

Thanks

Code:

Expand|Select|Wrap|Line Numbers
  1. If MsgBox("Do You Want To Create An Invoice?", vbDefaultButton1 + vbYesNo) = vbYes Then
  2.             Dim stDocName As String
  3.             stDocName = "rpt_Invoice"
  4.             DoCmd.OpenReport stDocName, acViewPreview
  5.         Else
  6.         End If
  7.  
  8.         DoCmd.Close acForm, "frm_New_Sale", acSaveNo
Oct 23 '08 #1
5 2415
missinglinq
3,532 Recognized Expert Specialist
If the report depends on data that you've just entered in your record, my guess would be because the report has no data. If this is the case, you need to save the record before opening the report:

Expand|Select|Wrap|Line Numbers
  1. If MsgBox("Do You Want To Create An Invoice?", vbDefaultButton1 + vbYesNo) = vbYes Then
  2.             Dim stDocName As String
  3.             If Me.Dirty Then Me.Dirty = True
  4.             stDocName = "rpt_Invoice"
  5.             DoCmd.OpenReport stDocName, acViewPreview
  6.         Else
  7.         End If
  8.  
  9.         DoCmd.Close acForm, "frm_New_Sale", acSaveNo
Welcome to Bytes!

Linq ;0)>
Oct 23 '08 #2
scottbouley
30 New Member
If I change the DoCmd.OpenRepor t to acViewNormal it prints with data. If I modify the close form code so that it errors out, the report stays up with the data.
Oct 24 '08 #3
DonRayner
489 Recognized Expert Contributor
If I change the DoCmd.OpenRepor t to acViewNormal it prints with data. If I modify the close form code so that it errors out, the report stays up with the data.
maybe something in the forms on close event is causing this. Why not set your break points and follow the code through it's execution to see what's hapening.
Oct 24 '08 #4
mshmyob
904 Recognized Expert Contributor
It could be as Linq says. It may have to do with no data be generated. In preview mode the events of the report's sections do not activate. Preview mode will not give the same results as print mode if the data is based on events of the report sections. Could this have something to do with it?

cheers,
Oct 24 '08 #5
NeoPa
32,568 Recognized Expert Moderator MVP
Linq,

What did you intend your line #3 to do?
Oct 24 '08 #6

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

Similar topics

1
3862
by: Andrew | last post by:
Hi All: I am using Access2000 and I find that the command to open an Access report in preview mode is very slow: DoCmd.OpenReport rptABC, acViewPreview, "", "" The scenario is this: - The following codes are written in the VB Applcation. - Prior to opening the report, I set its recordsource with a sql: ..Reports!rptABC.RecordSource = sSql. The sSql searches for a specific
1
2922
by: Filips Benoit | last post by:
Dear All, DoCmd.OpenReport RPT_TEST, A_PREVIEW, QueryAsFilter doesn't work correctly in A97 but works OK in A2K. Is this a bug for A97 ? Filip
1
2144
by: LoopyNZ | last post by:
Hi there, I've converted an Access 97 front end to Access 2000, but when I try to run a VBA DoCmd.OpenReport (e.g. DoCmd.OpenReport "rpt_programme_listing") line, Access completely crashes ("Microsoft Access for Windows has encountered a problem and needs to close. We are sorry for the inconvenience."). The reports themselves run fine when I double-click on them - it's only when I try to run them through code (including in the...
2
3573
by: Smartin | last post by:
Question about DoCmd.PrintOut in A97. I have a form on which all the controls are unbound. There is a large textbox that the user can type stuff in and a couple labels. I am trying to code a Print button to simply print out the form. Problem is, DoCmd.PrintOut only produces a blank page. (Actually once in testing, it printed the form module's code, but not the form.) In another app I am working on, PrintOut successfully prints the...
3
2735
by: news.onet.pl | last post by:
Hello! I have a question concerning to open the reports. I know that DoCmd.OpenReport is a obsolete form of opening the reports, but how to implement opening reports in VB using another VB code? I mean also OpenForm, OpenQuery etc. Thank you in advance for help Marcin
3
7784
by: enough2Bdangerous | last post by:
access runtime error 3011 on docmd.openreport -------------------------------------------------------------------------------- Access database (file format 2002-2003) generates reports with docmd.openreport but returns 3011 runtime error related to the printer. Switching Windows default printer is a work around but need to find out the cause. Help Desk updated printer driver on server and no runtime error for two months but we are receiving...
4
9468
by: Simon | last post by:
Dear reader, The syntax for Docmd.OpenReport is: OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs) Example The following example prints Sales Report while using the existing query
4
6060
by: robtyketto | last post by:
Greetings, I originally used a button on a from created via the button wizard (access 2007) to run my report which was based on a query. Since I wanted to add some validation I removed the button and added my own code (as below):- However the open report is just a preview and the user cant exit the preview screen without directly using access controls.
4
6658
by: gazza10001 | last post by:
Hi i hope you can help my company uses access and has modified for its needs usually what happens is you serach for the invoice by its number and then it brings all the information up such as entry fields and so there is a button you press which then takes to through to a print preview of the invoice and you print out the invoice but recent ly this message ahs started appearing and does not allow you to view the print preview of the invoice...
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7306
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.