Input Mask / Validation

G

Guest

I want to validate that a user has input the data
YYYY-YYYY.
For example 2004-2005
This is a text field an the - (hyphen) is actually stored in the table.
Any help with the input mask would be appreciated.
 
G

Guest

In the Input mask properties of the field, you can write
9999-9999

That will allow only numbers, and in this format
 
G

Guest

Thnaks for your reply but 9999-9999 does not insert the hyphen into the data.

I would like the hyphrn to be included in the data. Not just as an input
mask. That is, I don't want the hypen masked.

I want the data to be literally 2004-2005 or 2005-2006 etc

and to be able to validate the users input.
 
G

Guest

Does the years always follows 2005-2006 or 2002-2003, and it never jumps like
2002-2004
 
G

Guest

In that case you can create two fields, one that the user can input the first
year with an input mask of 9999, and the other field, locked, that you fill
the data in it based on the input of the user in the first field

On the after update event of the first field you should insert the code

If not isnull(Me.YearField) and Me.YearField <> "" then
Me.FullFieldName = Me.YearField & "-" & (clng(me.YearField) + 1)
End if

That way you sure that the format is right, and te user dont have to input
all the data. Also you wont have to check if the years follows.
 
R

Rajesh

Moran,

I donno whether i can reply here i am just at learner level but this is what
you are looking for

I dont feel there is a mask that could restrict the entry to 'hyphen' for
your fifth digit, but


Try the inputmask 9999&9999 ' input mask & accepts any character or
space but entry required

For the stored data to be like yyyy-yyyy
if txtDate is the control that takes this value

Private Sub txtDate_BeforeUpdate(cancel As Integer)
If Len(txtDate) > 4 Then
If Not Mid(txtDate, 5, 1) = "-" Then
MsgBox "Enter in the format '2004-2005' "
Me.Undo
End If
End If
End Sub

It works fine when i tested it!



Regards


Rajesh V R
rajeshontheweb at indiatimes dot com
 

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

Top