Solved Change Recordsource for a Sub.Report (1 Viewer)

Ksabai

Registered User.
Local time
Today, 12:03
Joined
Jul 31, 2017
Messages
104
i have 3 subforms in a form, want to change the recordsource for all the 3 forms if to be displayed in this form. iam using the following:

If TempVars!sRepRecSrc01 <> vbNullString Then Me.Pro_FormaDue.Report.RecordSource = TempVars!sRepRecSrc01

Error is You Entered and Expression That Has an Invalid Reference to the Property Form/Report

Someone Kindly help
 

theDBguy

I’m here to help
Local time
Today, 12:03
Joined
Oct 29, 2018
Messages
10,229
Where exactly did you put this code? On the main form or the subform, and which event?
 

Ksabai

Registered User.
Local time
Today, 12:03
Joined
Jul 31, 2017
Messages
104
sorry Typo Error
i have 3 subReports in a Report, want to change the recordsource for all the 3 subreports if to be displayed in this report. iam using the following:

If TempVars!sRepRecSrc01 <> vbNullString Then Me.Pro_FormaDue.Report.RecordSource = TempVars!sRepRecSrc01

Error is You Entered and Expression That Has an Invalid Reference to the Property Form/Report

Someone Kindly help
 

Ksabai

Registered User.
Local time
Today, 12:03
Joined
Jul 31, 2017
Messages
104
iam entering in the open event of the Main Report
 

theDBguy

I’m here to help
Local time
Today, 12:03
Joined
Oct 29, 2018
Messages
10,229
iam entering in the open event of the Main Report
Hi. When you refer to a subreport to change its record source, you'll have to make sure you're using the name of the control - not the name of the report it contains.
 

Ksabai

Registered User.
Local time
Today, 12:03
Joined
Jul 31, 2017
Messages
104
If TempVars!sRepRecSrc01 <> vbNullString Then [Reports]![rptFullDue]![Pro-FormaDue].Report.RecordSource = TempVars!sRepRecSrc01

The Above also Doesn't Seem to Work
 

theDBguy

I’m here to help
Local time
Today, 12:03
Joined
Oct 29, 2018
Messages
10,229
If TempVars!sRepRecSrc01 <> vbNullString Then [Reports]![rptFullDue]![Pro-FormaDue].Report.RecordSource = TempVars!sRepRecSrc01

The Above also Doesn't Seem to Work
Did you verify the name of your subreport control?
 

theDBguy

I’m here to help
Local time
Today, 12:03
Joined
Oct 29, 2018
Messages
10,229
Yes it is correct
Okay. What does "doesn't work" mean? Are you getting any errors? If so, what was the error message? Are you able to post a demo version of your db showing the problem?
 

Ksabai

Registered User.
Local time
Today, 12:03
Joined
Jul 31, 2017
Messages
104
let me try tomorrow, will let u know.
 

Ksabai

Registered User.
Local time
Today, 12:03
Joined
Jul 31, 2017
Messages
104
I used the below line in the Open Event of the Sub-Report and it working fine now.
If TempVars!sRepRecSrc01 <> vbNullString Then Me.RecordSource = TempVars!sRepRecSrc01

But now i get the error "you can't set the source property in print preview or after printing has started access" for about 4 times. i have 3 subreports. How to resolve this error
 

theDBguy

I’m here to help
Local time
Today, 12:03
Joined
Oct 29, 2018
Messages
10,229
I used the below line in the Open Event of the Sub-Report and it working fine now.
If TempVars!sRepRecSrc01 <> vbNullString Then Me.RecordSource = TempVars!sRepRecSrc01

But now i get the error "you can't set the source property in print preview or after printing has started access" for about 4 times. i have 3 subreports. How to resolve this error
It's a balancing act, isn't it. I'll wait for your sample file to take a look.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 20:03
Joined
Jul 9, 2003
Messages
11,509
I suspect you will have to set the sub-report record source from the the "Open Event" of the main report...
 

Ksabai

Registered User.
Local time
Today, 12:03
Joined
Jul 31, 2017
Messages
104
iam getting the error 2455, i don't know how to do this
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 20:03
Joined
Jul 9, 2003
Messages
11,509
iam getting the error 2455, i don't know how to do this
It's enormously helpful for the people trying to help you if you post the text that is produced with the error code, explaining what the error means...

I'm pretty sure the error text is not:- "i don't know how to do this"
 
Last edited:

arnelgp

error reading drive A:
Local time
Tomorrow, 03:03
Joined
May 7, 2009
Messages
9,336
there is No way you can change the Recordsource of a Report other than it's Open Event.
likewise there is no way you can set it's Recordset property.

you change the recordsource on to Open event of Each subReport.
additionally you can try:

If IsNull(TempVars("sRepRecSrc01"))=False Then …
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom