By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

Clear Date Field with Option Group

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Liz Malcolm wrote:
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.


Since this is a function, you need to update the dates.
Ex:
Me.StartDate = FirstPostDay()
Me.EndDate = LastPostDay()
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.