469,150 Members | 1,912 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,150 developers. It's quick & easy.

Set Control Source Value in SubReport at Runtime from MainReport

I have a report and a sub-report. I want to reuse the sub-report in the main report, but change the Control Source of a TextBox for each use. I am coding:
Expand|Select|Wrap|Line Numbers
  1. Reports![rptMain]![SubReportControlName].Report![Title Label].ControlSource = "=""Value A"""
I consistently get:

Run-time Error 2455 You entered an expression that has an invalid reference to the property Form/Report.

The code is in the Report Open event of the main report. What am I missing or not seeing?

Jan 25 '12 #1
1 3969
759 512MB
What is Value A ? It seems to be a variable, but become a string in your code.
Try to debug that by slightly change your code:]

Expand|Select|Wrap|Line Numbers
  1. Dim NewControlSource As String
  2. NewControlSource = "=""Value A"""
  3. Debug.Print NewControlSource
  4. Reports![rptMain]![SubReportControlName].Report![Title Label].ControlSource = NewControlSource
Of course you will obtain the same error message but now, when the code stop, you can see in Immediate window (press CTRL+G to open this window) that the value for your NewControlSource is all the time this string: ="Value A". And this not seems to be an SQL string.
Jan 25 '12 #2

Post your reply

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

Similar topics

6 posts views Thread by Mark Lees | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.