Input Mask (or is there a better way)

  • Thread starter Thread starter Karen
  • Start date Start date
K

Karen

I have a text box (expiration date) on a form and I want users to enter
data in that text box in a certain manner (ie: 01-2010). I would also
like them to be able to enter 'STABLE' if there is not an expiration
date. I currently have an input mask set on the properties of that
control (00\-0000;0;_) but it doesn't allow the entry of anything
except a date in that format.

Any ideas of what I can do to do this?

Karen S.
 
There is no way to use an Input Mask and allow non-compliant text as well.
What you could do is check the value in the BeforeUpdate event to see if it
matches one or the other.

Here is what the sub would look like:


Private Sub txtExpireDate_BeforeUpdate(Cancel As Integer)
If Me.txtExpireDate <> "STABLE" _
And (IsNumeric(Left(txtExpireDate, 2)) = False _
Or Mid(txtExpireDate, 3, 1) <> "-" _
Or IsNumeric(Right(txtExpireDate, 4)) = False _
Or IsDate(txtExpireDate) = False) Then
MsgBox "Please enter date as mm-yyyy or enter 'STABLE'"
Cancel = -1
End If
End Sub

I think I got everything.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Input Mask Errors 2
Input Mask Default Value 3
Input Mask 1
Input masks 4
Date Mask auto changes 1916 to 2016 2
input mask 4
Input masks 1
Input Mask for Date and Time 2

Back
Top