IsDate Leap Year

Pauldohert

Something in here
Local time
Yesterday, 19:24
Joined
Apr 6, 2004
Messages
2,097
I want to check dates entered as being valid - so if 30/02/2000 is entered I can advise the user that february has 28 or 29 days etc - but I can't work out how - if I format the text box dd/mm/yyyy I get a system error saying the entry is wrong but with no meaningful explanation. If I take the formatting off and use



If Not IsDate(Me!EndDate) Then
Cancel = True
MsgBox "Not a correct date!"
End If

it is throwing out 29/02/2004?

I am using an unbound text box.

Any help would be appreciated.

Paul
 
Last edited:
Thanks Stef - Thats half way there - what I want to do is have a global function which tells me is the date is valid of not and if appropriate tell me what is wrong - ie janurary only has 31 days! (I want to keep the text box formatted as dd/mm/yyyy) so I can easily call this function from loads of differant text boxes and check the date.

I am currently trying to check the date by converting it to a string and checking basics like if month = 01 then day can't be >31 etc etc.

The bit I can't get is where to fire the function , it has to be before the format check is done.

Its driving me nuts!!!


paul
 
;) Paul
I think it is not necessary to make a global function.
The every user must know that february can't have 30
days, and so on.
Yo can change a "MsgBox".
"Date is opposite the calendar" or something similar.
 
You would think that would be the case,

I would still like to just put a function name somewhere into the property sheet of the form or textbox and call a function which gives a specific reason.

Can I pass DataErr out to check for 2113 and then evaluate from here.

Is 2113 specific date is wrong format or do other format errors cause this problem.
 
Ok I have -

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 2113 Then
If Screen.ActiveControl.format = "dd/mm/yyyy" Then
MsgBox "Invalid Date"
Else
MsgBox DataErr & " " & AccessError(DataErr)
End If
End If
End Sub


this will probably do it if before Msgbox "Invalid Error" I call my function to return the specific reason, but still Idon't want to have to add code to all forms.
 
Ok have abandoned that and will just give a generic - Invalid Date msgbox, now am having the problem of 12/22/2000 being changed before the form error to 22/12/2000 -

If this happens I want an error as the likely hood is they meant 12/12/2000.


Argg!!!!
 

Users who are viewing this thread

Back
Top Bottom