Solved

Setting a textbox's controlsource in VBA on a report

Posted on 2001-08-21
8
528 Views
Last Modified: 2012-05-04
Simple question,

I have an unbound txtbox on a report, we can call it txtValue.  In the report I want to take the values from three other txtboxes that are dynamically generated, sum them, and have that value displayed in txtValue.  I don't understand why when I write the code and I reference txtValue that it doesn't give me the option for controlsource.  I have the summed value, i just don't have a way to give it to txtValue so it can be shown on the report.

Please help

Thanks,
Boody
0
Comment
Question by:boody
  • 3
  • 3
  • 2
8 Comments
 

Author Comment

by:boody
ID: 6409853
By the way, I'm using a recordset to get the values that I want for the other textboxes.
0
 
LVL 4

Expert Comment

by:maatthias
ID: 6409857
Try summing it in the report detail's OnFormat event.
0
 
LVL 57
ID: 6409876
Reports are a bit special.  In the way that controls and fields work together.  The approach is not to set the controlsource, but simply fill the control in with a value:

  Me![mycontrolname] = 1

  Would put a "1" in the control.  Replace the "1" with the rsult of your calculation.

Jim.
0
 

Author Comment

by:boody
ID: 6409935
Jim,

How do I replace the 1 with calculation?
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 57
ID: 6409972
You said you had the summed value correct?  Just do:

 Me![mycontrolname] = <summed value>

 in the OnFormat event of the section where the control is located.

  or did I miss something?

Jim.
0
 

Author Comment

by:boody
ID: 6410042
Actually, I have five textboxes that are receiving values.  I'm just trying to get the total of the first three. I got the total by using a variable and looping it through the first three.  That's in VBA, but I can't use that in the expression builder.

My report looks like this:

Year1 ... Year2 ...Year3 ...Year4 ...Year5 ... 3Yeartotal
12345.....12345....12345....12345....12345.....37305

I don't have a running sum or anything like that. All of the year captions and values get their data from a recordset since they change depending on what the year the user wants to specify.
0
 
LVL 4

Expert Comment

by:maatthias
ID: 6410063
In that case there shouldn't be any need for coding in OnFormat event.  Just set the textbox's controlsource as an expression sum it up.
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 20 total points
ID: 6410099
Then in the OnFormat, simply do:

 Me![year3Total] = Me![Year1] + Me![Year2] + Me![Year3]

for example (but you need to use your actual control names)

Jim.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now