Gasman
Enthusiastic Amateur
- Local time
- Today, 11:51
- Joined
- Sep 21, 2011
- Messages
- 14,234
I have a form and subform that logs employee hours.
The mainform has a combo to select the employee in the header and the subform in the detail.
The subform record source is a query.
As I amend the start and end times the Hours in the record automatically update. These hours are calculated and not stored. The query code is below
However the total control I have in the footer of the main form does not update to the correct value until I select another record, due to my setting it in the Current event of the subform.
I created a control in the footer of the subform with source of
and qryHours is
and then tried to reference that control as the source for my mainform total control as
but get the #Name? error, so amended the current event of the subform to use
I have since amended the code for each control to
which works fine in that it comes back to the amended record, except it goes to the first control in the datasheet, and I'd like it to go to the next as it would do after a Tab and not having this code.?
Now I only have a few controls on this form, so could hardcode the setfocus for the next control, but was wondering is there a neat way to just go to the next control on a form?
Subform source Query code
TIA
The mainform has a combo to select the employee in the header and the subform in the detail.
The subform record source is a query.
As I amend the start and end times the Hours in the record automatically update. These hours are calculated and not stored. The query code is below
However the total control I have in the footer of the main form does not update to the correct value until I select another record, due to my setting it in the Current event of the subform.
I created a control in the footer of the subform with source of
Code:
=NZ(DSum("[qryHour]","[qryHours]"),0)
Code:
SELECT Sum(IIf([DateType]=(15 Or 16),0,Round(calctime([starttime],[endtime],[lunch])/60,2))) AS qryHour, tblEmployeeDay.DateType
FROM tblEmployeeDay
WHERE (((tblEmployeeDay.EmployeeID)=[Forms]![frmEmployeeHours]![cboEmployee]) AND ((tblEmployeeDay.Processed) Is Null))
GROUP BY tblEmployeeDay.DateType
HAVING (((tblEmployeeDay.DateType)<>15 And (tblEmployeeDay.DateType)<>16));
Code:
=Forms![frmEmployeeDay]![txtSumHours]
Code:
Me.Parent.txtWeekHours = Me.txtSumHours
Code:
Dim strBookMark As String
strBookMark = Me.Bookmark
Application.Echo False
Me.Recalc
Me.Bookmark = strBookMark
Application.Echo True
Now I only have a few controls on this form, so could hardcode the setfocus for the next control, but was wondering is there a neat way to just go to the next control on a form?
Subform source Query code
Code:
SELECT tblEmployeeDay.*, nz(WeekdayName(Weekday([tblEmployeeDay].[DayDate],2),True),"") AS DayName, IIf([DateType]=15 Or [DateType]=16,0,calctime([starttime],[endtime],[lunch])/60) AS Hours
FROM tblDates INNER JOIN tblEmployeeDay ON tblDates.DayDate = tblEmployeeDay.DayDate
ORDER BY tblDates.DayDate;