Thread: Form questions
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Form questions

Of course 2 only checks a valid date, it doesn't force an input in a
prescribed format. This can get very complex and is probably not worth the
effort.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Bob Phillips" wrote in message
...
1. Check the value against your saved values using. Assuming it is on a
worksheet , use the Application.MATCH worksheetfunction.

Dim iMatch As Long

On Error Resume Next
iMatch =
Application.MATCH(Textbox1.Text,Worksheets("Sheet1 ").Range("A1:A100"),0)
On Error Goto 0
If iMatch < 0 Then
'not unique
End If

2. After the data has been completed, check the textbox text value with

the
IsDate function. I would do this on a commit button, and it fails you

reset
back to the textbox

With TextBox1
If Not IsDate(.Text) Then
'some sort of error message
.SelLength = Len(.Text)
.SelStart = 0
.SetFocus
End If
End With

3.

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 45 Then '-
KeyAscii = 0
End If
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Richard" wrote in message
...
Thanks to a few in the general forum, I have successfully used
Data-Validation. I have since then decided that the best way to have

data
entered is by using a form as there are thousands of records.

My questions a 1. How can I enforce a unique entry into a textbox?

2.
How can I enforce a date being entered (in mm/dd/yy format with the

"/").
3.
How can I enforce a phone number being entered ie 10 digits with no

dashes.
I have another entry for a serial number which would be x amount of
characters, but I think that would be the same as the phone number

scenario.

Thanks in advance,
Richard