PC Review


Reply
Thread Tools Rate Thread

change subreport source object

 
 
JohnLute
Guest
Posts: n/a
 
      11th Jan 2010
Access 2003/Win 2000

I'm trying to get this to work:
Private Sub Report_Open(Cancel As Integer)
Me.srptPKPhysicalAttributes.SourceObject = "srptPK" & Me.Type &
"PhysicalAttributes"
Me.srptPKMaterialAttributes.SourceObject = "srptPK" & Me.Type &
"MaterialAttributes"
Me.srptPKFinishingAttributes.SourceObject = "srptPK" & Me.Type &
"FinishingAttributes"
Me.srptPKPerformanceAttributes.SourceObject = "srptPK" & Me.Type &
"PerformanceAttributes"
End Sub


The report refuses to open. Does anyone see anything wrong?

The peculiar &Me.Type was suggested by Marshall Barton for use in the
OnChange Event of a tab control in a particular form. It works fine
for the form but perhaps not in the report...?

Thanks!
--
www.Marzetti.com
 
Reply With Quote
 
 
 
 
Tom Wickerath
Guest
Posts: n/a
 
      12th Jan 2010
Hi John,

The Me.Type part bothers me, because Type is considered a reserved word in
Access. Is this the name of a field in the recordsource for this report?

Problem names and reserved words in Access
http://allenbrowne.com/Ap****ueBadWord.html

If you do have a field or control named Type, I recommend changing the name.
If you don't want to do that right now, then use square brackets, like this:

Me.srptPKPhysicalAttributes.SourceObject = "srptPK" & Me.[Type] &
"PhysicalAttributes"

Also, make sure that this code module--and eventually all code
modules--include the two very important words Option Explicit near the top of
the module, usually like this:

Option Compare Database
Option Explicit

If you only see the line that reads "Option Compare Database", then add
Option Explicit to all modules. Then VBA editor so that you will get these
two very important words automatically added to all newly created modules:

Always Use Option Explicit
http://www.access.qbuilt.com/html/ge...tml#VBEOptions

Make sure that your code compiles without any compile errors. When viewing
any code module, click on:

Debug | Compile {ProjectName}

where {ProjectName} is the name of your VBA project (likely the same name as
the database, but it can be different).

> The report refuses to open.

Do you get any compile-time or run-time errors? Actually, you should get a
compile-time error with the Me.Type.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________

"JohnLute" wrote:

> Access 2003/Win 2000
>
> I'm trying to get this to work:
> Private Sub Report_Open(Cancel As Integer)
> Me.srptPKPhysicalAttributes.SourceObject = "srptPK" & Me.Type &
> "PhysicalAttributes"
> Me.srptPKMaterialAttributes.SourceObject = "srptPK" & Me.Type &
> "MaterialAttributes"
> Me.srptPKFinishingAttributes.SourceObject = "srptPK" & Me.Type &
> "FinishingAttributes"
> Me.srptPKPerformanceAttributes.SourceObject = "srptPK" & Me.Type &
> "PerformanceAttributes"
> End Sub
>
>
> The report refuses to open. Does anyone see anything wrong?
>
> The peculiar &Me.Type was suggested by Marshall Barton for use in the
> OnChange Event of a tab control in a particular form. It works fine
> for the form but perhaps not in the report...?
>
> Thanks!
> --
> www.Marzetti.com

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
change subreport source object JohnLute Microsoft Access Reports 10 13th Jan 2010 03:38 PM
change subreport source object johnlute Microsoft Access Reports 0 11th Jan 2010 01:48 PM
Source Object changing on save of subreport kelli.sanders@kingcounty.gov Microsoft Access Reports 2 8th May 2008 05:43 PM
Source Object in subreport =?Utf-8?B?YmVuag==?= Microsoft Access Reports 3 6th Dec 2006 03:30 PM
How to Change the Source Object for a Subreport with a CountThem Control doyle60@aol.com Microsoft Access VBA Modules 8 31st Mar 2006 04:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:04 AM.