Control Data entry

singingshiver

Registered User.
Local time
Today, 18:26
Joined
Jul 23, 2002
Messages
51
How can I control my form so that the data entered into a field cannot begin with a number 0?
 
Run this sub on the BeforeUpdate event of the textbox:

Private Sub Textbox_BeforeUpdate(Cancel As Integer)

Dim str As String

str=Me!TextboxName

If Asc(Left(str,1))=48 then 'First character is a zero
msgbox "Whatever message you want to give to the user",vbokonly
Cancel=True
Me!TextboxName.Undo
End if

End Sub
 
Much obliged it worked a treat
 

Users who are viewing this thread

Back
Top Bottom