473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How do you set a variables for controls in a subreport?

I am trying to run a report which displays the data horizontally across the page to make the report more readable. I managed to do this by having a list of empty fields and assign the control source based on a filter which is prompt by a open event. The code is as follows where jobs(1,i) is a list of the jobs:

Expand|Select|Wrap|Line Numbers
  1.     Set Cnt = Reports![Job Subtrade Analysis].Controls
  2.  
  3.     For i = 0 To 6
  4.         If i <= UBound(jobs, 2) Then
  5.             Cnt("R" & i + 1).ControlSource = "CCSubCost_GFA.[" & jobs(1, i) & "]"
  6.             Cnt("R1" & i + 1).ControlSource = "CCSubCost_FU.[" & jobs(1, i) & "]"
  7.             Cnt("R2" & i + 1).ControlSource = "CCSubCost.[" & jobs(1, i) & "]"
  8.             Cnt("R" & i + 1).Visible = True
  9.             Cnt("R1" & i + 1).Visible = True
  10.             Cnt("R2" & i + 1).Visible = True
  11.             Cnt("P" & 1 + i).Caption = jobs(1, i)
  12.         Else
  13.             Cnt("R" & i + 1).ControlSource = ""
  14.             Cnt("R1" & i + 1).ControlSource = ""
  15.             Cnt("R2" & i + 1).ControlSource = ""
  16.             Cnt("R" & i + 1).Visible = False
  17.             Cnt("R1" & i + 1).Visible = False
  18.             Cnt("R2" & i + 1).Visible = False
  19.         End If
  20.     Next
  21.  
This code works great but the problem that I am running into is in this report there is a sub report and I cannot set a variable to loop through the controls of the sub report. I tried using the following but it returned an error stating that the subreport could not me found.
Expand|Select|Wrap|Line Numbers
  1.     Set Cnt = Reports![Job Subtrade Analysis]![CCSubCost_Subreport].Controls
  2.  
Any suggestions would be greatly appreciated.
Oct 11 '11 #1
3 2309
NeoPa
32,556 Expert Mod 16PB
What's the name of your Subform/Subreport control on your main [Job Subtrade Analysis] report?
Oct 11 '11 #2
The control has the same name as the report so CCSubCost_Subreport.
Oct 11 '11 #3
NeoPa
32,556 Expert Mod 16PB
In that case you need either :
Expand|Select|Wrap|Line Numbers
  1. Set Cnt = Reports![Job Subtrade Analysis]![CCSubCost_Subreport]!Controls
or :
Expand|Select|Wrap|Line Numbers
  1. Set Cnt = Reports![Job Subtrade Analysis]![CCSubCost_Subreport].Report.Controls
See Referring to Items on a Sub-Form for the explanation why.
Oct 12 '11 #4

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

Similar topics

9
by: Downstreamer | last post by:
Design is as follows: A form for the user to input criteria to be used as the where part of the report's recordsource. This includes a multiselect list box as part of the criteria selection. ...
6
by: Steve Jorgensen | last post by:
I tried to fix a problem for a client today in which report sections and even individual text controls in some of their reports are being split across page boundaries. Of course, I was thinking...
3
by: kmacon | last post by:
I have a form that contains a command button. The command button's OnClick event builds a report using the CreateReport and CreateReportControl functions and then opens the main report. I set...
2
by: Jeff | last post by:
Damn this is frustrating. I have used subreports for years and never had this problem. I have used these things more times than I can remember. Never have I had this problem....
2
by: Roger | last post by:
How can I access subreport objects from vba? Sample code would be appreciated.
2
by: Ron | last post by:
I have a report let's call rptOne. On rptOne I have a subreport called srptOne. On srptOne I have a subreport called srptTwo. Sometimes, srptTwo is there and shows it's data and sometimes not,...
11
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RowSource of a Master Report is: Me.RowSource = "TableOrQueryName"
3
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RecordSource of a Master Report is: Me.RecordSource = "TableOrQueryName"
3
by: Simon van Beek | last post by:
Dear reader, How to change the RecordSource for a subReport. For forms the syntaxes is:
2
by: whethergirl | last post by:
I have a Main report in my database with two Subreports ("Level" and "Quality"). Each (sub)report is based on a different query, but all queries include the same field ("Location") from the same...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.