Verify number

A

AHopper

When a number like (20 digits) 77801474347002273657 is
entered into a text box "LabelOnePack" by using the
following in the AfterUpdate event, I get the correct
data I want to enter in two other text boxes.
If Nz(Me.LabelOnePack) >= 1 Then
Dim RegNo As String
RegNo = Nz(Me.LabelOnePack)
Me.RegisteredLabel = CStr(Left("" & RegNo & "", 19))
Me.CheckDigit = CStr(Right("" & RegNo & "", 1))
End If

I get the following result:
"RegisteredLabel" 7780147434700227365
"CheckDigit" 7

The Fields in the table where the data is stored are set
to text so they will allow letters.
How can I verify that the entry is 20 digits with no
letters?

If it is not correct I want to send a message, undo the
update and exit the sub.

Thank you for your help.
Allan
 
K

Ken Snell [MVP]

Use this test:

If Len(Me.RegisteredLabel) = 20 And _
IsNumeric(Me.RegisteredLabel) = True Then
' the text string is 20 characters long and
' it contains only numbers
Else
End If
 
A

AHopper

Ken
Thank you very much for your help.

Allan
-----Original Message-----
Use this test:

If Len(Me.RegisteredLabel) = 20 And _
IsNumeric(Me.RegisteredLabel) = True Then
' the text string is 20 characters long and
' it contains only numbers
Else
End If


--

Ken Snell
<MS ACCESS MVP>




.
 

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


Top