473,322 Members | 1,352 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,322 software developers and data experts.

DoCmd.OpenReport Problem or Limitation?

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 2398
missinglinq
3,532 Expert 2GB
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
If I change the DoCmd.OpenReport 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 Expert 256MB
If I change the DoCmd.OpenReport 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 Expert 512MB
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,556 Expert Mod 16PB
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
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...
1
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
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...
2
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...
3
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?...
3
by: enough2Bdangerous | last post by:
access runtime error 3011 on docmd.openreport -------------------------------------------------------------------------------- Access database (file format 2002-2003) generates reports with...
4
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...
4
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...
4
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.