Hi!
I tried the search function of this forum to look for a solution for my problem but I can't seem to find it so I posted it instead, maybe I missed a few threads, not sure coz i'm quite dizzy right now.
I have a form with around 45 textboxes, but i'm currently stuck up with a simple problem if you look at it but i've been juggling 3 hours trying to accomplish it.
Here's the situation:
#1. I have a Textbox Named Date1(In the form, I have Date1-Date15)
#2. The Textbox Format is in Short Date since I need to enter valid dates
#3. I created a function that compared the entered date against 2 dates that act as the upper and lower limit of my valid date range.
#4. I'm also trying to catch the event that if the user enters the textbox and tries to exit it, a Prompt will tell the user that it is mandatory.
Can anyone help me? Whenever I try and my focus is in Date1, when I exit it, it doesn't fire the exit codes
I tried the search function of this forum to look for a solution for my problem but I can't seem to find it so I posted it instead, maybe I missed a few threads, not sure coz i'm quite dizzy right now.
I have a form with around 45 textboxes, but i'm currently stuck up with a simple problem if you look at it but i've been juggling 3 hours trying to accomplish it.
Here's the situation:
#1. I have a Textbox Named Date1(In the form, I have Date1-Date15)
#2. The Textbox Format is in Short Date since I need to enter valid dates
#3. I created a function that compared the entered date against 2 dates that act as the upper and lower limit of my valid date range.
Code:
Private Function CheckEntryDate(DateFrom As Date, DateTo As Date, DateEntered As Date)
If DateEntered >= DateFrom And DateEntered <= DateTo Then
'Valid Date!
Else
MsgBox "This field is required!"
CheckEntryDate = True
End If
End Function
#4. I'm also trying to catch the event that if the user enters the textbox and tries to exit it, a Prompt will tell the user that it is mandatory.
Code:
Private Sub Date1_Exit(Cancel As Integer)
If IsDate(Date1.Text) Then
Cancel = CheckEntryDate(Me!DateFrom, Me!DateTo, Me!Date1)
ElseIf Me!Date1 = "" Then
MsgBox "This Field is Required!"
Cancel = True
End If
End Sub
Can anyone help me? Whenever I try and my focus is in Date1, when I exit it, it doesn't fire the exit codes