|
-
January 10th, 2000, 03:09 AM
#1
Checking Date range
I want to make a small dialog box which contains
"From Date" and "To Date" input user fields .
I need to validate that the dates inserted by the user are correct.
Is there any code around that do somthing similar?
-
January 10th, 2000, 03:23 AM
#2
Re: Checking Date range
try the IsDate function. It returns False for invalid dates.
-
January 10th, 2000, 04:03 AM
#3
Re: Checking Date range
I would do it with two date picker controls:
private Sub Form_Initialize()
'initialize controls
DTPicker1.Value = Now
DTPicker2.Value = Now
DTPicker1.MaxDate = Now
DTPicker2.MaxDate = Now
DTPicker2.MinDate = Now
End Sub
private Sub DTPicker1_Validate(Cancel as Boolean)
'set the earliest date for dtpicker2 equal to the selected date from dtpicker1
DTPicker2.MinDate = DTPicker1.Value
End Sub
You can retrieve the values entered with the value property of each dtpicker control. For any further questions, post them here! ;-)
Michael Vlastos
Automation Engineer
Company SouthGate Hellas SA
Development Department
Athens, Greece
-
January 10th, 2000, 04:35 AM
#4
Re: Checking Date range
Try this
Private Sub Command1_Click()
Dim Date1 As Date
Dim Date2 As Date
Date1 = Format(Text1, "dd/mm/yyyy")
Date2 = Format(Text2, "dd/mm/yyyy")
If Date1 - Date2 >= 0 Then
MsgBox "Please enter the correct dates"
End If
End Sub
It works for me.
Good luck.
Leo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|