Hey all,
I've got a completed program / macro, I'm now trying to throw in an error check(s). The first field in my dialog box, asks for a date in a specific format, MM-DD-YY. I have a simple text underneath the textbox that states to enter that way, but in an effort to make the code more efficient against bad user input, I'd like to have it check against a set parameter.
First, I tried using this:
Dim A as Integer
Dim dash
dash = "-"
FDate = A + A + dash + A + A + dash + A + A
Then, I put it into a simple If / Then
(Install_Date is the textbox field from the Dialog box)
If Install_Date <> Fdate Then
MsgBox" Please enter date in correct format"
GoTo Dialog:
End If
I could get it to work if the date was input as 07-0606, but it got me thinking if the user entered something absurd such as a month or day that didn't exist, it'd still accept it, short of programming an entire calendar. I looked for date formats, like CVDate but kept coming up with nothing that would work for what I'm trying to do. If anyone has any ideas or has any existing code, I'd more than appreciate the help. The other fields I'm going to error check might be easier, such as if the first / last name fields contain a numeric then to error, and if a zipcode entry is longer than 5 digits then to again error. Again, I thank any and all that respond.
- 51
I've got a completed program / macro, I'm now trying to throw in an error check(s). The first field in my dialog box, asks for a date in a specific format, MM-DD-YY. I have a simple text underneath the textbox that states to enter that way, but in an effort to make the code more efficient against bad user input, I'd like to have it check against a set parameter.
First, I tried using this:
Dim A as Integer
Dim dash
dash = "-"
FDate = A + A + dash + A + A + dash + A + A
Then, I put it into a simple If / Then
(Install_Date is the textbox field from the Dialog box)
If Install_Date <> Fdate Then
MsgBox" Please enter date in correct format"
GoTo Dialog:
End If
I could get it to work if the date was input as 07-0606, but it got me thinking if the user entered something absurd such as a month or day that didn't exist, it'd still accept it, short of programming an entire calendar. I looked for date formats, like CVDate but kept coming up with nothing that would work for what I'm trying to do. If anyone has any ideas or has any existing code, I'd more than appreciate the help. The other fields I'm going to error check might be easier, such as if the first / last name fields contain a numeric then to error, and if a zipcode entry is longer than 5 digits then to again error. Again, I thank any and all that respond.
- 51