Converting and Calculating Dates on a Form

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Freinds,


I have a TextBox- txtNumDays which is associated with TestStartDate and

TestEndDate. If you put Number of Days and TestStartDate, it calculates

the TestEndDate. I also have VacationBeginDate and VacationEndDate on a

different form and different table, I want the txtNumDays to calculate
the TestEndDate by Subtracting the number of days between
VacationBeginDate and
VacationEndDate. The number of days between VacationBeginDate and
VacationEndDate is provided by the users on TesterVacationForm.


I am using the following module to calculate the TestEndDate:
Public Function MyAdd(dtStart As Date, intDays As Integer) As Date


Dim dtEnd As Date
Dim I As Integer
Dim dtMiddle As Integer

Dim frmTesterVacation As Form_frmTesterVacation
Dim frmSystem As Form_frmSystem
Dim dbo_TESTERNME As TableDef
Dim NUMOFDAYS As Field



I = 0
dtEnd = dtStart

If intDays < 1 Then
Exit Function
End If


Do While I < intDays
If Nz(Form_frmSystem.TESTER_NME_ID) <> "" Then

dtMiddle = [Form_frmTesterVacation].NumberofDays

If dtMiddle = -1 Then
Exit Do
End If
End If

dtEnd = dtEnd + dtMiddle + 1

Select Case Weekday(dtEnd)
Case 2 To 6
' regular week day.MON - Fri..count one day
I = I + 1
End Select
Loop


MyAdd = dtEnd


End Function



If possible please solve this issue, i would really really appreciate
it.

.



Relevant Pages

  • RE: Converting and Calculating Dates on a Form
    ... Dim intDayCount As Integer ... > the TestEndDate. ... I also have VacationBeginDate and VacationEndDate on a ... > Public Function MyDateAdd(dtStart As Date, intDays As Integer) As Date ...
    (microsoft.public.access.forms)
  • Converting Days into Days
    ... If you put Number of Days and TestStartDate, ... the TestEndDate. ... I also have VacationBeginDate and VacationEndDate on a ... Dim frmTesterVacation As Form_frmTesterVacation ...
    (microsoft.public.access.forms)
  • Converting and Calculating Dates on a Form
    ... If you put Number of Days and TestStartDate, ... the TestEndDate. ... I also have VacationBeginDate and VacationEndDate on a ... I want the txtNumDays to calculate ...
    (microsoft.public.access.forms)
  • RE: Converting Days into Days
    ... Both use a table named Holidays with a field named Holdate. ... Dim intDayCount As Integer ... I also have VacationBeginDate and VacationEndDate on a ... > Public Function MyAdd(dtStart As Date, intDays As Integer) As Date ...
    (microsoft.public.access.forms)
  • Re: Converting and Calculating Dates on a Form
    ... you'll want to use DateDiffand DateAdd() to actually perform the calculatons as they're designed specifically to work with dates. ... If you need the TestEndDate to fall on a weekday, you can use DatePartto test if the date falls on a Sat or Sun and if so add 1 or 2 ) to the inital TestEndDate to shift it. ... I also have VacationBeginDate and VacationEndDate on a different form and different table, I want the txtNumDays to calculate the TestEndDate by Subtracting the difference of VacationBeginDate and VacationEndDate. ... Public Function MyDateAdd ...
    (microsoft.public.access.forms)