Engineer1279
New Member
- Joined
- Feb 28, 2013
- Messages
- 19
OK, so I have a userform with some text boxes that I have specially formatted to accept only date values in the form of mm/dd/yy. By default they are blank. I have a check in one of my codes that looks like this
Where DateBox is this specially formatted TextBox and checkdate is a future date being checked against.
So if DateBox has a value in it AND that value is greater than the date being checked against the returend string is Neoprene, otherwise it is blank.
Well the problem I have is when the first condition returns FALSE, i.e. when DateBox is empty, the DateValue half still gets evaluated and returns a type missmatch error or something like that because DateValue("") returns an error. I have line of code 8 times, one for Neoprene, squeegee, etc. So the name of the text boxes are each unique and I am using M1, M2, M3, etc. I could probably nest the seond condition in a conditional of its own below the first condition, but I want to avoid that. It seems like there is a simple answer to this problem that I am missing.
For other reasons, use of "On Error Resume Next" doesn't work for this situation because it causes a result opposite to what I want to happen. So anyway, if someone could help resolve this for me I would appreciate it.
Code:
If DateBox <> vbNullString And DateValue(DateBox) > checkdate Then
M1 = "NEOPRENE" & Chr(13)
Else
M1 = "" & Chr(13)
End If
Where DateBox is this specially formatted TextBox and checkdate is a future date being checked against.
So if DateBox has a value in it AND that value is greater than the date being checked against the returend string is Neoprene, otherwise it is blank.
Well the problem I have is when the first condition returns FALSE, i.e. when DateBox is empty, the DateValue half still gets evaluated and returns a type missmatch error or something like that because DateValue("") returns an error. I have line of code 8 times, one for Neoprene, squeegee, etc. So the name of the text boxes are each unique and I am using M1, M2, M3, etc. I could probably nest the seond condition in a conditional of its own below the first condition, but I want to avoid that. It seems like there is a simple answer to this problem that I am missing.
For other reasons, use of "On Error Resume Next" doesn't work for this situation because it causes a result opposite to what I want to happen. So anyway, if someone could help resolve this for me I would appreciate it.