473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Clear Date Field with Option Group

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
1 2792
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Doslil | last post by:
I have a form which is designed to only data entery.When i try to open to form in the run form I have the following errors 1. when i open the form I get an error message saying "Access can't...
2
by: BlackFireNova | last post by:
I have an Access 2003 mdb which contains software records. I need to sort on a particular type of software, and then identify and count how many copies there are per each group of that type...
2
by: Rene | last post by:
I have a master "attendance" report that also has two "attendance" sub-reports...each collecting data from a different group...and totaling those present at the end. I chose sub-reports because...
2
by: nmakhan | last post by:
I have a validation summary that I use soley for my Required Field Validators. That works fine if I do things that way up to a point, if by chance the validation summary says "Date field...
28
Ericks
by: Ericks | last post by:
I want to highlight new data that has been entered in my database since a last meeting so it is easy to see in a subform’s table what info is new. In my database I have a table called...
3
by: 6afraidbecause789 | last post by:
If able, can someone please help make a Where clause that strings together IDs in a multi-select listbox AND includes a date range. I wasn’t thinking when I used the code below that strings...
3
by: murch.alexander | last post by:
I made a simple public function to set and return a date value (see below). I have a number of queries that call up the function to get the "As Of Date," which is typically set to today's date....
8
beacon
by: beacon | last post by:
Hi everybody, I'm having a terrible time trying to accomplish what I thought would be extremely easy. I have three date fields on a form (DischargeDate, ReceivedDate, and AuditedDate) and I'm...
25
smithj14
by: smithj14 | last post by:
I have a form that has an option group (fraReports) which holds a list of reports to print. This part works fine. I select a report name and click print and that report opens. Now I want to add a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.