By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,225 Members | 1,434 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,225 IT Pros & Developers. It's quick & easy.

Totals Row

P: 9
Background: database is simple and controlled by one form with multiple tabs that include subforms under each tab.

I have a totals row in a subform that counts the number of rows above it in order to tell me how many times something has happened to an employee (given an award, punished, etc.)

I would like a way for that total to show in a text box on another of the forms tabs. So how do I get a total from a datasheet to a text box? I need it to do this for each employee record when the employee is selected from the drop down menu controling the form. (this part already works for the other fields)
Seems like it should be easy but I have had no luck yet. Can someone either help me with this or point me in the right direction to speed up my journey.
Jul 1 '09 #1
Share this Question
Share on Google+
7 Replies


beacon
100+
P: 579
If you haven't done so already, create a textbox on the main form where you want the totals to appear. In the control source for this text box, type in the following:
Expand|Select|Wrap|Line Numbers
  1. =[Name of Subform].[Form]![Name of Field on Subform with Total]
  2.  
Replace [Name of Subform] with the actual name of your subform and replace [Name of Field on Subform with Total] with the actual name of the text box that holds the value on your subform.

I don't think you have to worry about the tabs as long as you reference the subform correctly. Just make sure the text box is on the tab you want it on.
Jul 1 '09 #2

P: 9
I am not referencing a field on the subform, I am referencing a totals row on the datasheet. I basically need to populate the textbox with the number of rows on the subform table.
Jul 1 '09 #3

P: 9
Ok, I was over-complicating this by trying to pull from the total row in the datasheet. Here I am with one line of VB code and I am a single step away from where I need to be. What I have is below and it populates the textbox with the total number of awards given to all records. Now I need to limit it only to the record that is open.

Private Sub Form_Current()
'Populates the totalawards field with the number
'of awards received by the employee
Me.txtTotalAwards.Value = DCount("awardID", "tblawards")
End Sub
Jul 1 '09 #4

beacon
100+
P: 579
@IntelSldr
Hi Intel,

I'm sorry about that. I misunderstood what you were asking.
Jul 2 '09 #5

P: 9
That's ok, happens to the best of us and it is hard to diagnose over a forum. I am still working on getting the VB code to only pull the active record though.
Jul 2 '09 #6

P: 9
It is still not limiting the results to one employee, anyone else with any ideas?
Jul 9 '09 #7

P: 9
nevermind, found another thread that covered record counts in subforms.

Expand|Select|Wrap|Line Numbers
  1. =[subawards].[Form].[RecordsetClone].[RecordCount]
  2.  
Jul 9 '09 #8

Post your reply

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