Another subform total problem

hzeigler4

Registered User.
Local time
Yesterday, 22:08
Joined
Apr 18, 2007
Messages
42
Ok now I have an issue with totaling on the subform. I have a main form(frmEmpHours) and a subform(subfrmEmpHours). I added a textbox to the sub forms footer to total the number of hours. When I open the main form, you select an employee(first on in the list) then enter a date(for testing purposes use 4/21/07). Then the subform fills with the appropriate records. However no total displays and it keeps saying calculating in the bottom of the form and the mouse is going crazy!!! Anyone know why????????????????? I am attaching the database.
 

Attachments

First, to make the total hours worked field work, change it from this:

=Sum([txtHoursWorked])

To this:

=Sum([HoursWorked])

You want to sum the field data, not the name of the field. Give me a few minutes to figure out the flickering. Something is in an infinite loop. I'll post back if someone doesn't beat me to it first.

EDIT/UPDATE: The problem is in how you're linking your subform to your main form with the Master and Child Fields. I don't want to just spill the beans on what you've done here, but investigate that on your own and you should figure it out.

Hint: Note that if you remove either Child or Master reference from the subform, the flickering stops, but the link also seems to break. How would you fix that? How do you properly link the two using Master/Child links?

There are an awful lot of posts on this forum referring to how to do that, and in the long run, leading you in the right direction is better than just explicitly saying "Do A, then B, then C". :)

EDIT/UPDATE 2: To avoid the wild goose chase, here are some more direct hints:

1) You shouldn't link child and master fields on calculated fields. Things might blink unexpectedly, as if they're in an infinite loop (but are instead constantly 'calculating').
2) While the references to columns in a combobox are zero-based (column(0) = the first column, column(1) = the second column, etc.), the bound column property is one-based (bound column 1 = the first column, etc.). Confusing, yes, but good to know.
3) A combobox isn't a calculated field, unlike a certain parent/child combo you currently have.

Hopefully, that should do it. :)

EDIT/UPDATE 3: The attachment has it corrected, but there might be a password involved. Please try to get it on your own first. If you're really stuck, I'll repost the attachment sans the password. (Feeling a mixture of evil and compassion, sort of like my GF... :P).
 

Attachments

Last edited:
hmm Ok I think I may be even more confused now after reading your post. I didn't think there was anything wrong with my master/child links. The reason I have empID and DateWorked as links is because I want the user to select and employye on the parent form. Then enter a date to enter hours for. Then the subform will filter based on the selected employee and the date worked. And it will also make dateworked(on the subform) = to what was entered in the parent form for any records added.

The way I made the forms is the only way I know how to do this. I read through the forums on child/master links and none of them seemed to work based on how I want the subform to filter. I just tried to download your database and yes as you said it is password protected.
 
If I take my sum total out of the footer of the subform it does not flicker. Is it not related to the textbox that it is summing? I need to get the total number of hours from the subform and display it in the main form.

And niether of my master/child links are a calculated field so not sure how that would be an issue.
 
Your EmpID in the Master Field (main form) is based on a calculated field. When the ControlSource property starts with "=", that's a calculated field.

I'll download the example real quick and take off the password so you can see the changes I made.

EDIT: Uploaded DB with no password on it. Look at what I did to the Master Field link, and look at the employee name drop-down to see how I adjusted the bound column and such. These are the things I was trying to point you toward.
 

Attachments

I need to get the total number of hours from the subform and display it in the main form.

Keep the calculation in the footer of the subform, and then just hide the footer. To reference it in the Main Form, you can treat the subform just like any other object, as in this (I don't remember your form names exactly, but this is close):

SubEmpHours!TotalHoursWorked
 
Duh on my part. Sorry but I do not know why I didn't realize I was setting the EmpId to the combo box as being calculated. I have never set the master to a cmb before. It all seems clear to me now. I must say I have learned a great deal with this. Thanks a million!!!!
 

Users who are viewing this thread

Back
Top Bottom