Connecting Tech Pros Worldwide Help | Site Map

Procedure Assistance Requested - Dates

Kenny G
Guest
 
Posts: n/a
#1: Nov 12 '05
I would like some assistance on writing a procedure.

I have a StartDate and an EndDate. If the EndDate is less than the
StartDate then I need to undo the input in the EndDate, let the user
know that the date is incorrect, and have the user put in the correct
date.

Thanks in advance.

Kenny G
Phil Stanton
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Procedure Assistance Requested - Dates


Private Sub ToDate_BeforeUpdate(Cancel As Integer)

Dim Date1 As Date, Date2 As Date
Date1 = Format$(FromDate, "mmm\/dd\/yyyy")
Date2 = Format$(ToDate, "mmm\/dd\/yyyy")

If DateDiff("d", Date1, Date2) < 0 Then
MsgBox "From date is after To Date by " & DateDiff("d", Date1,
Date2) & " days", vbCritical
Cancel = True
Else
MsgBox "To date is after From Date by " & DateDiff("d", Date1,
Date2) & " days", vbInformation
End If
End Sub

You need a similar thing before Update of thr FromDate

The formatting rubbish seems to get over the problem with we(The Brits)
having a less illogical date format than the Americans.
Also lots of unneccessary stuff in the message box, but it will allow you to
check the arithmetic

Phil


"Kenny G" <kg_321@hotmail.com> wrote in message
news:810d01a6.0312041203.5c960b5a@posting.google.c om...[color=blue]
> I would like some assistance on writing a procedure.
>
> I have a StartDate and an EndDate. If the EndDate is less than the
> StartDate then I need to undo the input in the EndDate, let the user
> know that the date is incorrect, and have the user put in the correct
> date.
>
> Thanks in advance.
>
> Kenny G[/color]


Kenny G
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Procedure Assistance Requested - Dates


Phil,

That worked out just fine. I appreciate your help. I did notice the
differences in dates on SQL server with the ways different countries
write their dates.

Thanks again, Kenny G

"Phil Stanton" <discussion@stantonfamily.co.uk> wrote in message news:<3fcfada1$0$99607$65c69314@mercury.nildram.ne t>...[color=blue]
> Private Sub ToDate_BeforeUpdate(Cancel As Integer)
>
> Dim Date1 As Date, Date2 As Date
> Date1 = Format$(FromDate, "mmm\/dd\/yyyy")
> Date2 = Format$(ToDate, "mmm\/dd\/yyyy")
>
> If DateDiff("d", Date1, Date2) < 0 Then
> MsgBox "From date is after To Date by " & DateDiff("d", Date1,
> Date2) & " days", vbCritical
> Cancel = True
> Else
> MsgBox "To date is after From Date by " & DateDiff("d", Date1,
> Date2) & " days", vbInformation
> End If
> End Sub
>
> You need a similar thing before Update of thr FromDate
>
> The formatting rubbish seems to get over the problem with we(The Brits)
> having a less illogical date format than the Americans.
> Also lots of unneccessary stuff in the message box, but it will allow you to
> check the arithmetic
>
> Phil
>
>
> "Kenny G" <kg_321@hotmail.com> wrote in message
> news:810d01a6.0312041203.5c960b5a@posting.google.c om...[color=green]
> > I would like some assistance on writing a procedure.
> >
> > I have a StartDate and an EndDate. If the EndDate is less than the
> > StartDate then I need to undo the input in the EndDate, let the user
> > know that the date is incorrect, and have the user put in the correct
> > date.
> >
> > Thanks in advance.
> >
> > Kenny G[/color][/color]
Closed Thread