473,505 Members | 14,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open report from VBA, without printing

5 New Member
Hi!

I have experienced a a really odd problem when writing an Access application. I would programatically open a report (because i need to pass a value to it) with DoCmd.OpenReport. I would like to open it for viewing, not in print preview (as there the recordsource couldn't be modified anymore), like when you open it from the command bar with the button "Report View".
The odd thing is, that apparently there's no way to simply view the report without immediately printing it :-). I tried the code
DoCmd.OpenReport "ReportName", acViewReport, , , acWindowNormal, "value_to_pass"
with every view mode. As i know with acViewReport it has to display the report instead of printing it... Is this some bug or i am missing something?:
Sep 14 '07 #1
5 48420
nico5038
3,080 Recognized Expert Specialist
Use the Preview like:

DoCmd.OpenReport "ReportName", acViewPreview, , , , "OpenArgs"

Nic;o)
Sep 14 '07 #2
Piedone
5 New Member
Use the Preview like:

DoCmd.OpenReport "ReportName", acViewPreview, , , , "OpenArgs"

Nic;o)
Thanks, that would do it, but as i have written, unfortunately it's not possible to modfiy the recordsource prooperty in print preview, so it's not possible either to make a report with a customized query.
I made a new try and have explored that with an open argument (even with an empty one) Access 2007 doesn't print. That's OK, but Access 2003 still does...
Sep 14 '07 #3
nico5038
3,080 Recognized Expert Specialist
When I want a "dynamic" recordset I just manipulate the query before activating the report.
In general however using a filter gives enough flexibility, but incase you really need the query to change use this code before the Docmd.OpenReport:

Expand|Select|Wrap|Line Numbers
  1. Dim qd as DAO.Querydef
  2.  
  3. set qd = currentdb.querydefs("qryRptYours")
  4. qd.SQL = "select x from tblY where x =" & Me.X
  5.  
Getting the idea ?

Nic;o)
Sep 15 '07 #4
ADezii
8,834 Recognized Expert Expert
Thanks, that would do it, but as i have written, unfortunately it's not possible to modfiy the recordsource prooperty in print preview, so it's not possible either to make a report with a customized query.
I made a new try and have explored that with an open argument (even with an empty one) Access 2007 doesn't print. That's OK, but Access 2003 still does...
If you wish to make any modifications to a Report prior to actually Opening/Previewing it, open the Report Hidden first, make your changes, then Re-Open in the proper Mode.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "rptEmployee", acViewNormal, , , acHidden
Sep 15 '07 #5
Piedone
5 New Member
Thanks a lot to both of you, it works!
Sep 15 '07 #6

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

Similar topics

0
3741
by: eddie wang | last post by:
Excel open automatically without giving a dialog box option to Open/Save/Cancel using filesys.createTextFile. How to pop up the dialog box option to Open/Save/Cancel? Thanks.
1
2640
by: diskoduro | last post by:
Hi! I'm trying to get help to an unexpected problem that has appeared while I was writing a new application. I want to opeon a report of product sales by filtering previously from a listbox in a...
0
1339
by: Michael Dekson | last post by:
Access 97. I make a report and I want first to see report and then print report without type CONTROL + P. Can I make some button or can I see print button in toolbar meny. Thanks
0
1078
by: BFord | last post by:
Using Acc2000, only the report itself not printing. The following have been tested, with no problem: 1) the print drivers are fine. 2) printed the query (source of the report) 3) printed...
1
2465
by: sonicfun2006 | last post by:
I have SQL Server Database and MS Access 2003 is connected with ODBC. I have very large amount of records in various tables. The database is very dynamic as it changes every minute. I’m trying to...
0
938
by: alexalok | last post by:
Hi , I developing an application VS dotnet 2003 using C#. I want to use crystal report without using DSN,so that i can change Database on run time. if anybody can help me. thanx.
0
8409
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have problems printing a .rdlc report directly to the printer. I have created such a report without Datasource, I just fill some parameters in this report. With the ReportViewer I am...
4
9639
by: Phil Stanton | last post by:
I am opening a report (in Preview) from a menu system I use the following code if there is no data in a report Private Sub Report_NoData(Cancel As Integer) MsgBox "There are no errors in...
4
4482
by: pacarv | last post by:
I've created a database in Access 2003 with multiple reports that are accessable from the switchboard. The switchboard also has a print button. The user selects the report from the menu which then...
0
7216
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,...
0
7098
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
7303
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
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
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...

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.