Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Reports / Printing / December 2005

Tip: Looking for answers? Try searching our database.

Recordsource Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David W - 12 Dec 2005 20:51 GMT
Is there a way to set the recordsource of a subreport through code?
I have got a form that I am wanting to use for setting the criteria for a
query to view a report by.
I am having problems with setting the recordsource of the subreport.

I tried: example from command button on form

Docmd.OpenReport "myreport",acPreview
Reports!myreport.mysubreport!employee.Recordsoource = "newrecordsource"

I get the response that it doesnt support this.
I dont like specifying filters because of some issues with them in reports
on different PCs.
Any Ideals?
Marshall Barton - 12 Dec 2005 21:20 GMT
>Is there a way to set the recordsource of a subreport through code?
>I have got a form that I am wanting to use for setting the criteria for a
[quoted text clipped - 9 lines]
>I dont like specifying filters because of some issues with them in reports
>on different PCs.

The place where you can reliably set a report's record
source at runtime is in the report's own Open event.

In the case of a subreport, this can only be done the first
time the subreport appears in the main report.  The code to
deal with this is something like:

Sub Report_Open(...
Static Initialized As Boolean
If Not Initialized Then
    Me.RecordSource = Forms!theform.newrecordsource
    Initialized = True
End If
End Sub

Signature

Marsh
MVP [MS Access]

David W - 13 Dec 2005 19:50 GMT
How would you check to see if a specific form is open, and if it is open,
change the recordsource? I am wanting to change the recordsource to a query
if a specific form is open, and when its not leave it set to a table.

>>Is there a way to set the recordsource of a subreport through code?
>>I have got a form that I am wanting to use for setting the criteria for a
[quoted text clipped - 24 lines]
> End If
> End Sub
Marshall Barton - 14 Dec 2005 00:20 GMT
>How would you check to see if a specific form is open, and if it is open,
>change the recordsource? I am wanting to change the recordsource to a query
>if a specific form is open, and when its not leave it set to a table.

Here's a good way:

Signature

Marsh
MVP [MS Access]

Marshall Barton - 14 Dec 2005 00:22 GMT
>>How would you check to see if a specific form is open, and if it is open,
>>change the recordsource? I am wanting to change the recordsource to a query
>>if a specific form is open, and when its not leave it set to a table.

Whoops.
Here's a good way:
http://www.mvps.org/access/forms/frm0002.htm

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.