Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grabbing total hours on a form after adding entry

Status
Not open for further replies.

Gaffi1

Technical User
Apr 23, 2004
70
US
We have a payroll system where we have a mainform that has a drop down of employee names. We select an employee from the drop down and it pulls up data in the subform for all their records entered in so far, and we can add more or delete from the subform. In the subform we enter the start and stop times, have a field that calculates total hours and stores this data into a table called payroll.

The thing that is lacking is something on the sub or main form that shows the total hours between all the records for that person, and updates everytime we add a new record so I can see not only how many hours worked that entry, but all together.

I made a query that calculates the total hours based on the current person selected, put that information on a subform, and added that subform to the main form, but it's only accurate when I change to another person and click back. I need it to be updated automatically and can't figure out how.

Thanks in advance for your help!
 
How are ya Gaffi1 . . . .

In the [blue]AfterUpdate[/blue] event of the [blue]origional subForm[/blue], try:
Code:
[blue]   Forms![purple][b]MainFormName[/b][/purple]![purple][b]NewSubFormName[/b][/purple].Requery[/blue]

Calvin.gif
See Ya! . . . . . .
 
Were on the right track but this didn't work exactly. What we need to do get that command to work is to get the focus back from the subform to the mainform and then run the refresh/requery command. Any suggestions?

I tried running visual basic code DoCmd.SetFocus but it won't compile because of the SetFocus command. Thanks!
 
OK, played with it one more time and figured out how to set the focus back to the main form. Now, does anyone know how to set it up so that the process would go something like this...

In the LostFocus property of the field StopTime in the subform, setfocus to Combo3 in the mainform.

Refresh the form.

>>>Heres the step I need help with...
Change focus back to the subform

Thanks Everyone!
 
Gaffi1 said:
[blue]In the LostFocus property of the field StopTime in the subform, setfocus to Combo3 in the mainform.
[/blue]
Code:
[blue]   Forms![purple][b]MainFormName[/b][/purple]!Combo3.SetFocus[/blue]

Calvin.gif
See Ya! . . . . . .
 
I'm sorry, I'm trying to find my way back to the subform now. I tried using that code, directing it to a field in the subform but it errors out on compile. Thanks!
 
Gaffi1 . . . . .

If the [blue]focus[/blue] in on the [blue]MainForm[/blue]:
Code:
[blue]   Forms!MainFormName!subFormName.Form!TextBoxName[/blue]

Calvin.gif
See Ya! . . . . . .
 
Boy is this a headache project, lol...

So far we have everything up and running like we hoped. The last task is after we run our command to update the main form (returning the correct total hours in the second subform) and focus is returned to the subform, I need the subform to focus on the last record. However, the last record command always pulls up a blank data entry screen instead of the last record for that individual like we need. Any last suggestions on this problem? Thanks!
 
Gaffi1 said:
[blue]However, the last record command always pulls up a blank data entry screen[/blue]
[ol][li]I don't know which command your using to goto the last record, but use:
Code:
[blue]DoCmd.RunCommand acCmdRecordsGoToLast[/blue]
[/li]
[li]in your code, you should be going to record after you set focus to the subform.[/li][/ol]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top