473,406 Members | 2,377 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,406 software developers and data experts.

What is the correct VBA code for opening a report from a subform?

Daniel B
I created a subform so that you could click an ID# and it would open another form with the information for that ID#. I would like to do the exact same thing, but open a report instead.

The code i used to open the form is...

Private Sub TIR___Click()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "formNew"

stLinkCriteria = "[TIR #]=" & Me![TIR #]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

I tried the same code to try to open the report, except i changed the form to report and changed the other names, but it would'nt open the report, instead it would print the report. Any comments or advice would be helpfull.

Dan B
Aug 16 '10 #1

✓ answered by gershwyn

The OpenReport method takes 6 parameters total, with all but the first being optional.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)
The second parameter (View) here is what is getting you. The default value is acViewNormal, which will print the report directly. You probably want to open it either in report mode or print preview mode. Try one of the following:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport stDocName, acViewReport, , stLinkCriteria
  2. DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria

2 1588
gershwyn
122 100+
The OpenReport method takes 6 parameters total, with all but the first being optional.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)
The second parameter (View) here is what is getting you. The default value is acViewNormal, which will print the report directly. You probably want to open it either in report mode or print preview mode. Try one of the following:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport stDocName, acViewReport, , stLinkCriteria
  2. DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
Aug 16 '10 #2
Nice I used acViewPreview and it worked perfectly.

Thanks gershwyn.
Aug 16 '10 #3

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

Similar topics

4
by: Jeff | last post by:
I have a need to open a report in design mode immediately before opening it in preview, to change the Minimum and Maximum scale on an axis on a chart. This results in a flash of the report in...
1
by: Evets Htims | last post by:
This is Access 2003. Have a report that includes three subreports stacked on top of one another (they display order items). In the report On Open I build a recordset (to get a value from a foreign...
1
by: Marie | last post by:
I am opening a report from a form. How do I get the report to open in front of the form? I tried setting the form's Visible property to False and the report displayed too small to preview. To try...
3
by: Marius Rus | last post by:
I have a project in C# that do the followings: From an csv text file it is taking datas and inserted into an paradox database. My problem it is that when writing into the paradox database it is...
1
by: mike3040 | last post by:
What is an OOB report?
3
by: pv1 | last post by:
Hello, I am somewhat new to Access and vba, but am trying to complete a request that has been made of me. Access version 2002 WindowsXP. At this point these text boxes are bound to the table...
6
by: lyle fairfield | last post by:
"dpcman01" <bob@dpcman.com.auwrote in news:48e4a87b$0$31804$afc38c87@news.optusnet.com.au: Much of the code at the MVP site gave excellent results last century. If I were opening a report in...
21
jinalpatel
by: jinalpatel | last post by:
I have three option buttons (1 option group): construction projects, non construction projects and aquisition projects. I have created a form with more than 35 data entry fields for each of this...
0
by: techuse | last post by:
what is drill down report? how to create a drill down report in jasper i report 3.71? i am using oracle data base.
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...
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...

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.