473,583 Members | 3,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change the recordset of an Access report on Open

When I open an Access form I can have no recordset specified, then in
the form's OnOpen event I can do something like:
Me.paramaters = "@SomeColum n = 22)"
Me.recordsource = "dbo.sproc1 23"

But I can't do this in a report as it will prompt me for the
parameters, even though they seem to be defined ahead of the
recordsource.

I have worked around this by opening reports to a bogus recordsource
that has the same underlying parameters and tables but is designed to
return only one record, then in the report's OnOpen event I specify the
recordsource I want.This seems like a waste of speed and bandwidth.

The reason I am doing this is because I have some forms with multiple
recordsources that share the same report and in the OnOpen of the
report I user something like:

me.recordsource = Forms!myForm.Re cordSource
Am I missing something here?

Thanks,
lq

Nov 13 '05 #1
8 10755
lauren quantrell wrote:
When I open an Access form I can have no recordset specified, then in
the form's OnOpen event I can do something like:
Me.paramaters = "@SomeColum n = 22)"
Me.recordsource = "dbo.sproc1 23"

But I can't do this in a report as it will prompt me for the
parameters, even though they seem to be defined ahead of the
recordsource.

I have worked around this by opening reports to a bogus recordsource
that has the same underlying parameters and tables but is designed to
return only one record, then in the report's OnOpen event I specify the
recordsource I want.This seems like a waste of speed and bandwidth.

The reason I am doing this is because I have some forms with multiple
recordsources that share the same report and in the OnOpen of the
report I user something like:

me.recordsource = Forms!myForm.Re cordSource
Am I missing something here?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

No. You're do it correctly. The recordset is not retrieved until after
the Report's Open event finishes. Therefore, all the code you run in
the Open event occurs before any data is retrieved, and, there isn't a
waste of speed & bandwidth.

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQjX7joechKq OuFEgEQL8oACgxu hV4ty3j5nqzrJeg p2WOfp9HfEAoOLK
X7SwcK/5IG7VYrLbqFv3+p Uq
=BIAT
-----END PGP SIGNATURE-----
Nov 13 '05 #2
And dare I ask you have tried this using an Access project with
parameters passed to the stored procedure recordsource?

lq

MGFoster wrote:
lauren quantrell wrote:
When I open an Access form I can have no recordset specified, then in the form's OnOpen event I can do something like:
Me.paramaters = "@SomeColum n = 22)"
Me.recordsource = "dbo.sproc1 23"

But I can't do this in a report as it will prompt me for the
parameters, even though they seem to be defined ahead of the
recordsource.

I have worked around this by opening reports to a bogus recordsource that has the same underlying parameters and tables but is designed to return only one record, then in the report's OnOpen event I specify the recordsource I want.This seems like a waste of speed and bandwidth.

The reason I am doing this is because I have some forms with multiple recordsources that share the same report and in the OnOpen of the
report I user something like:

me.recordsource = Forms!myForm.Re cordSource
Am I missing something here?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

No. You're do it correctly. The recordset is not retrieved until

after the Report's Open event finishes. Therefore, all the code you run in
the Open event occurs before any data is retrieved, and, there isn't a waste of speed & bandwidth.

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQjX7joechKq OuFEgEQL8oACgxu hV4ty3j5nqzrJeg p2WOfp9HfEAoOLK
X7SwcK/5IG7VYrLbqFv3+p Uq
=BIAT
-----END PGP SIGNATURE-----


Nov 13 '05 #3
lauren quantrell wrote:
And dare I ask you have tried this using an Access project with
parameters passed to the stored procedure recordsource?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yes, I did; and got an error. Found this KB article which explained how
to fix it:

http://support.microsoft.com/default...b;en-us;300693

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQjYaN4echKq OuFEgEQJ6igCgj8 FBboSDICQxyIEld Gmi8oWzK8gAoPFv
wztRIHYaDOKn9QL OanGHb/Ly
=vO2O
-----END PGP SIGNATURE-----
Nov 13 '05 #4
Lauren,

I have a fairly large ADP. In my experience you cannot change the report
recordsource or parameters in the code of the report. There are two ways to
accomplish a changing recordsource for a report.

1) Before running the report, your application can open it in design mode
(which can be hidden) and change the necessary setting, save it, close it
and reopen it. There are several negatives to this methodology. First,
your app MUST be and adp (not ade) and your users must have full Access
installed (Not runtime), as you are actually doing design changes, albiet
through code.

2) My preferred method is to base a report off of a stored procedure and
have the input parameters refer to a "Control" form that stores all of the
necessary info that the stored procedure needs to return a recordset to the
report. If you have very different data, you will most likely want to open
a different report based on an option on the "Control" form.

Using method two, you would set your report recordsouce in the properties
window to "dbo.SomeStored Procedure". Then in the inputParameters you would
put something like:

@Param1 INT = Forms("ControlF orm")("txtBoxWi thInfo1"), @Param2 VARCHAR(20)
= Forms("ControlF orm")("txtBoxWi thInfo2")

HTH,
Jim
"lauren quantrell" <la************ *@hotmail.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
When I open an Access form I can have no recordset specified, then in
the form's OnOpen event I can do something like:
Me.paramaters = "@SomeColum n = 22)"
Me.recordsource = "dbo.sproc1 23"

But I can't do this in a report as it will prompt me for the
parameters, even though they seem to be defined ahead of the
recordsource.

I have worked around this by opening reports to a bogus recordsource
that has the same underlying parameters and tables but is designed to
return only one record, then in the report's OnOpen event I specify the
recordsource I want.This seems like a waste of speed and bandwidth.

The reason I am doing this is because I have some forms with multiple
recordsources that share the same report and in the OnOpen of the
report I user something like:

me.recordsource = Forms!myForm.Re cordSource
Am I missing something here?

Thanks,
lq



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 13 '05 #5
Jim,
Thanks for your response.
I use your method of parameters in all of my reports. The problem is
the recordsource of the form changes among many stored procedures.
It's starting to look like I need to create many reports and open the
appropriate one based on the stored procedure of the form, rather than
the other way around of changing the stored procedure of the report...
Thanks,
lq
J. Clay wrote:
Lauren,

I have a fairly large ADP. In my experience you cannot change the report recordsource or parameters in the code of the report. There are two ways to accomplish a changing recordsource for a report.

1) Before running the report, your application can open it in design mode (which can be hidden) and change the necessary setting, save it, close it and reopen it. There are several negatives to this methodology. First, your app MUST be and adp (not ade) and your users must have full Access installed (Not runtime), as you are actually doing design changes, albiet through code.

2) My preferred method is to base a report off of a stored procedure and have the input parameters refer to a "Control" form that stores all of the necessary info that the stored procedure needs to return a recordset to the report. If you have very different data, you will most likely want to open a different report based on an option on the "Control" form.

Using method two, you would set your report recordsouce in the properties window to "dbo.SomeStored Procedure". Then in the inputParameters you would put something like:

@Param1 INT = Forms("ControlF orm")("txtBoxWi thInfo1"), @Param2 VARCHAR(20) = Forms("ControlF orm")("txtBoxWi thInfo2")

HTH,
Jim
"lauren quantrell" <la************ *@hotmail.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
When I open an Access form I can have no recordset specified, then in the form's OnOpen event I can do something like:
Me.paramaters = "@SomeColum n = 22)"
Me.recordsource = "dbo.sproc1 23"

But I can't do this in a report as it will prompt me for the
parameters, even though they seem to be defined ahead of the
recordsource.

I have worked around this by opening reports to a bogus recordsource that has the same underlying parameters and tables but is designed to return only one record, then in the report's OnOpen event I specify the recordsource I want.This seems like a waste of speed and bandwidth.

The reason I am doing this is because I have some forms with multiple recordsources that share the same report and in the OnOpen of the
report I user something like:

me.recordsource = Forms!myForm.Re cordSource
Am I missing something here?

Thanks,
lq

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet

News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption

=----

Nov 13 '05 #6
Thanks for your reply. I read the link but unfortunately that structure
in the Microsoft solution (strRecordSourc e = "Exec [Sales By Year]
'1/1/97','12/31/98'") isn't available to Access2K which my appliation
is.
lq

Nov 13 '05 #7
The other option is to create a "Master" stored procedure that is the record
source for the report. From within that SP, you can call the appropriate
stored procedure that you really want based on an input parameter. You
would just use a case statement within the master to call each of the "Sub"
procedures.

Jim

"lauren quantrell" <la************ *@hotmail.com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
Jim,
Thanks for your response.
I use your method of parameters in all of my reports. The problem is
the recordsource of the form changes among many stored procedures.
It's starting to look like I need to create many reports and open the
appropriate one based on the stored procedure of the form, rather than
the other way around of changing the stored procedure of the report...
Thanks,
lq
J. Clay wrote:
Lauren,

I have a fairly large ADP. In my experience you cannot change the

report
recordsource or parameters in the code of the report. There are two

ways to
accomplish a changing recordsource for a report.

1) Before running the report, your application can open it in design

mode
(which can be hidden) and change the necessary setting, save it,

close it
and reopen it. There are several negatives to this methodology.

First,
your app MUST be and adp (not ade) and your users must have full

Access
installed (Not runtime), as you are actually doing design changes,

albiet
through code.

2) My preferred method is to base a report off of a stored procedure

and
have the input parameters refer to a "Control" form that stores all

of the
necessary info that the stored procedure needs to return a recordset

to the
report. If you have very different data, you will most likely want

to open
a different report based on an option on the "Control" form.

Using method two, you would set your report recordsouce in the

properties
window to "dbo.SomeStored Procedure". Then in the inputParameters you

would
put something like:

@Param1 INT = Forms("ControlF orm")("txtBoxWi thInfo1"), @Param2

VARCHAR(20)
= Forms("ControlF orm")("txtBoxWi thInfo2")

HTH,
Jim
"lauren quantrell" <la************ *@hotmail.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
When I open an Access form I can have no recordset specified, then in the form's OnOpen event I can do something like:
Me.paramaters = "@SomeColum n = 22)"
Me.recordsource = "dbo.sproc1 23"

But I can't do this in a report as it will prompt me for the
parameters, even though they seem to be defined ahead of the
recordsource.

I have worked around this by opening reports to a bogus recordsource that has the same underlying parameters and tables but is designed to return only one record, then in the report's OnOpen event I specify the recordsource I want.This seems like a waste of speed and bandwidth.

The reason I am doing this is because I have some forms with multiple recordsources that share the same report and in the OnOpen of the
report I user something like:

me.recordsource = Forms!myForm.Re cordSource
Am I missing something here?

Thanks,
lq



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet

News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World!

120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption

=----



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 13 '05 #8
Jim,
Yours is the perfect solution. I will do just that whern I get the
time.
lq

Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
23863
by: Nicola | last post by:
Hi Everyone, I am new to programming and would like to know how to open an access Report from within vb 6. I am trying to write a program to organise cross stitch threads. I have found out how to use a database table but all I want to do now is to click a command button to display this access report. Any suggestions please ?????
13
2690
by: Seth Spearman | last post by:
Hey guys, I have the following code: '****************************************************** If Not Me.NewRecord Then Dim rs As DAO.Recordset Dim strBookmark As String Set rs = Forms("frmMaster").RecordsetClone 'set an instance of form master recordset clone
15
13280
by: Mark C | last post by:
All, I have exhaustingly been looking through the newsgroups in search of a way to systemically output an Access 97 report to a pdf file using the full version of Adobe Acrobat. I want the user to be able to click a button and have the Access report saved as a pdf in a directory specified by me the programmer. I have seen a posting by...
3
3706
by: Newbie | last post by:
This is my first try at running Access Report by Visual Basic I have the following code in my button press event: ' 2 - Show print preview objAccess.DoCmd.OpenReport "Invoices", 2, , ".=" & _ intCurrentInvoice objAccess.DoCmd.Maximize
4
9184
by: dkelly925 | last post by:
I have an Access Report that I am trying to enter an "If Statement" that when a certain field exceeds a certain number of lines or a certain number of characters that field is not visible and another field on a second page becomes visible. Following is my "If Statement" that doesn't work. My issue is how to refer to the number of lines or...
1
22762
by: ellenh | last post by:
I have read postings on the similar subject including the posting from 2003 shown below. This process works fine to display a single page snapshot report in PowerPoint. I need to display subsequent pages from the same snapshot file in subsequent slides in PowerPoint. I realize that it is possible to add VB code to the Snapshot Viewer...
6
5219
by: DeniseY | last post by:
I have an Access report that is created on the fly by the user selecting the fields to be included. The Access report comes out fine, but I want it to automatically output to an Excel spreadsheet. Again, I have this part working. But the fields in the resulting spreadsheet are in a different order than the Access report. (Example: The fields in...
17
21158
by: kkk1979 | last post by:
I have been using access as front end and SQL as Back end. I need help in generating an access report, by using a stored procedure with input parameters as record source. I tried the following code, but getting an error.Can't I use recordset as record source for the report. Dim sDate As String Dim eDate As String Dim rsbatf As New...
5
13334
by: sphinney | last post by:
All, How do you use an ADO recordset with an Access 2002 report? The ADO recordset was created by querying an external SYBASE database. Once I get the data, how to I get my Access report to use the recordset? Thanks for your help, sphinney
0
7895
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...
0
7826
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...
0
8327
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7935
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...
0
8193
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...
1
5701
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3818
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...
0
3843
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1157
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...

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.