G
Guest
I have a field that has different length numbers entered. If the length is =
32 then I need the program to get rid of the first 16 digits and the last 4
digits. If the length is different then 32 then follow the validation rule.
The code below is what I tried, but it didn't work. What am I doing wrong?
I could setup the validation in the code. What is better?
---------This is the validation rule---------
Like "1Z????????????????" Or Like "???????????" Or Like "????????????" Or
Like "??????????????????????" Or Like "????" Or Like "????????????????"
------------end validation rule--------------
--------start code-----------
Private Sub TrackingNo_BeforeUpdate(Cancel As Integer)
Dim strRTTrackNo As String
Dim strFinalTrackNo As String
If Len(Me.TrackingNo) = 32 Then
Right(Me.TrackingNo, 4) = strRTTrackNo
Left(strRTTrackNo, 16) = strFinalTrackNo
Me.TrackingNo = strFinalTrackNo
End If
End Sub
-------------end code------------
32 then I need the program to get rid of the first 16 digits and the last 4
digits. If the length is different then 32 then follow the validation rule.
The code below is what I tried, but it didn't work. What am I doing wrong?
I could setup the validation in the code. What is better?
---------This is the validation rule---------
Like "1Z????????????????" Or Like "???????????" Or Like "????????????" Or
Like "??????????????????????" Or Like "????" Or Like "????????????????"
------------end validation rule--------------
--------start code-----------
Private Sub TrackingNo_BeforeUpdate(Cancel As Integer)
Dim strRTTrackNo As String
Dim strFinalTrackNo As String
If Len(Me.TrackingNo) = 32 Then
Right(Me.TrackingNo, 4) = strRTTrackNo
Left(strRTTrackNo, 16) = strFinalTrackNo
Me.TrackingNo = strFinalTrackNo
End If
End Sub
-------------end code------------