I've spent 4 days trying to find a work around this problem.
I have 2 subforms and 1 main form. In one subform I have a calendar control and a text field named "CurrentDate". In the other subform I have a query with three fields to display a persons scheduled vacation days by date, hours and temporary holding hours.
I implemented the code below to set the CurrentDate field to match the individual dates of each row in the query because I have some logic that checks to see what other time is available on the vacation calendar.
Private Sub Hours_GotFocus()
h = [Hours]
Forms![frmPTOScheduler-Overview]![sfrmPTOScheduler_ScheduledTime].Form![tbHoldingHours].Value = h
d = Date
Forms![frmPTOScheduler-Overview]![sfrmPTOScheduler_BusinessSchedule2].Form![CurrentDate].Value = d
End Sub
This part of it works great. My problem comes in when I try to use the calendar control on my first subform. It still works and changes the date in CurrentDate field like it is suppose to;however, when I try to add a vacation selection which is a field located on my main form the Current date reverts back to the date in my second subform.
I've tried using SetFocus, Refresh and Requery in different combinations to clear the CurrentDate field of that variable selection but it still keeps changing back to the last date in the 2nd subform.
Help! Any ideas would be greatly appreciated!
Dan G
I have 2 subforms and 1 main form. In one subform I have a calendar control and a text field named "CurrentDate". In the other subform I have a query with three fields to display a persons scheduled vacation days by date, hours and temporary holding hours.
I implemented the code below to set the CurrentDate field to match the individual dates of each row in the query because I have some logic that checks to see what other time is available on the vacation calendar.
Private Sub Hours_GotFocus()
h = [Hours]
Forms![frmPTOScheduler-Overview]![sfrmPTOScheduler_ScheduledTime].Form![tbHoldingHours].Value = h
d = Date
Forms![frmPTOScheduler-Overview]![sfrmPTOScheduler_BusinessSchedule2].Form![CurrentDate].Value = d
End Sub
This part of it works great. My problem comes in when I try to use the calendar control on my first subform. It still works and changes the date in CurrentDate field like it is suppose to;however, when I try to add a vacation selection which is a field located on my main form the Current date reverts back to the date in my second subform.
I've tried using SetFocus, Refresh and Requery in different combinations to clear the CurrentDate field of that variable selection but it still keeps changing back to the last date in the 2nd subform.
Help! Any ideas would be greatly appreciated!
Dan G