Hello and TIA. I have a DE form with an option group that if daily is
selected todays date is used for start and end date, if weekly is
selected Monday - Friday is used. I am trying to add a manual date
selection to clear the start and end date to allow the end user input
other days. I have taken into account our financial 1st and last day
of the month. I was able to break the option group into a select
case, but I cannot get the date field to clear out. The dates are
displayed in unbound text boxes with the code as the control source.
Function FirstPostDay()
Dim FirstOfMonth As Date
'Calculate the last day of the month by using DateSerial
'get the year from reporting year text box, get the month from the
reporting month combo box
FirstOfMonth = DateSerial(Forms!frmDataEntryMenu.txtFinYr,
Forms!frmDataEntryMenu.cboDHQMonthSelect.Column(1) , 1)
Select Case Weekday(FirstOfMonth)
Case vbSaturday
FirstPostDay = FirstOfMonth + 2
Case vbSunday
FirstPostDay = FirstOfMonth + 1
Case Else
FirstPostDay = FirstOfMonth
End Select
End Function
Function LastPostDay()
Dim LastOfMonth As Date
LastOfMonth = DateSerial(Forms!frmDataEntryMenu.txtFinYr,
Forms!frmDataEntryMenu.cboDHQMonthSelect.Column(1) + 1, 0)
Select Case Weekday(LastOfMonth)
Case vbSaturday
LastPostDay = LastOfMonth - 1
Case vbSunday
LastPostDay = LastOfMonth - 2
Case Else
LastPostDay = LastOfMonth
End Select
End Function
Function FinclWeekStart() As Date
Dim startOfWeek As Date
Dim intx As Integer
intx = Forms!frmDataEntryMenu.optTransSelect.Value
'startOfWeek = IIf(Forms!frmdataentrymenu.optTransSelect.Value =
1, Date, Date - Weekday(Date, vbMonday) + 1)
Select Case intx
Case 1
startOfWeek = Date
Case 2
startOfWeek = Date - Weekday(Date, vbMonday) + 1
Case 3
strSql = "Update forms!frmDataEntryMenu.txtFinFromDate SET
forms!frmdataentrymenu.txtFinFromDate = "";"
End Select
'Need if no date leave the field blank here
If startOfWeek < FirstPostDay Then
FinclWeekStart = FirstPostDay
Else
FinclWeekStart = startOfWeek
End If
End Function
Function FinclWeekEnd()
Dim EndOfWeek As Date
'EndOfWeek = IIf(Forms!frmDataEntryMenu.optTransSelect.Value = 1,
Date, Date - Weekday(Date, vbMonday) + 5)
Dim intx As Integer
intx = Forms!frmDataEntryMenu.optTransSelect.Value
Select Case intx
Case 1
EndOfWeek = Date
Case 2
EndOfWeek = Date - Weekday(Date, vbMonday) + 5
Case 3
strSql = "Update forms!frmDataEntryMenu.txtFinToDate SET
forms!frmdataentrymenu.txtFinToDate = "";"
End Select
'Need if no date leave the field blank here
If EndOfWeek > LastPostDay Then
FinclWeekEnd = LastPostDay
Else
FinclWeekEnd = EndOfWeek
End If
End Function
Again TIA for any and all help. Liz Malcolm