thomas.szwed
01-04-2008, 06:52 AM
Hallo,
I have built a userform for my users to enter some data. The users enter a date in one of the textboxes. I want to know if there is anyway i can put in some validation on that textbox so dates can only be entered in one format (dd/mm/yyyy)???
Also the form is used to change data so a user may open up a record and change the data so the validation on that textbox always needs to be in place whether they are adding or editing a record.
Here is some code i used to validate another textbox - this is to make sure only unique numbers are entered. Perhaps it may be somerthing along the lines of this?
Private Sub txtPersNum_AfterUpdate()
If Not IsError(Application.Match(Val(Me.txtPersNum.Text), Sheets("Master Data").Columns(4), 0)) Then
MsgBox "That Personnel Number is already assigned - try another", vbCritical, "Duplicate found"
With Me
.txtPersNum.Value = vbNullString
.btnExport.Enabled = False
End With
End If
I have built a userform for my users to enter some data. The users enter a date in one of the textboxes. I want to know if there is anyway i can put in some validation on that textbox so dates can only be entered in one format (dd/mm/yyyy)???
Also the form is used to change data so a user may open up a record and change the data so the validation on that textbox always needs to be in place whether they are adding or editing a record.
Here is some code i used to validate another textbox - this is to make sure only unique numbers are entered. Perhaps it may be somerthing along the lines of this?
Private Sub txtPersNum_AfterUpdate()
If Not IsError(Application.Match(Val(Me.txtPersNum.Text), Sheets("Master Data").Columns(4), 0)) Then
MsgBox "That Personnel Number is already assigned - try another", vbCritical, "Duplicate found"
With Me
.txtPersNum.Value = vbNullString
.btnExport.Enabled = False
End With
End If