G
Guest
I have a form that allows me to split an alph-numeric (ex: D0015) but when
the code runs the zeroes are dropped. I need to have it split to D and 0015.
Below is the code that I have. It works well but its the zero thing I can't
figure out.
Dim Check As String
Dim lngLastRecordNo As Long
Dim lngPos As Long
Check = True
'go to last record
DoCmd.GoToRecord acActiveDataObject, , acLast
' update file
lngLastRecordNo = Me.CurrentRecord
DoCmd.GoToRecord acActiveDataObject, , acFirst
' Outer loop
Do
' Innerloop
' Set repetitions
For lngPos = 1 To Len(Me.FileNumber) Step 1
If Mid(Me.FileNumber, lngPos, 1) >= 0 And Mid(Me.FileNumber,
lngPos, 1) <= 9 Then
'found start of numbers
Me.FileLetter = Left(Me.FileNumber, lngPos - 1)
Me.FileNo = CLng(Mid(Me.FileNumber, lngPos))
'have finished for this one
Exit For
Else
'a letter get next chr
End If
Next lngPos
'this is how we exit when all records have be done
If Me.CurrentRecord = lngLastRecordNo Then Exit Do
DoCmd.GoToRecord acActiveDataObject, , acNext
'we never get to true we exit when all records have been visited
Loop Until Check = False
Can anyone see what needs to be added or changed?
Thanks for any help given.
*** John
the code runs the zeroes are dropped. I need to have it split to D and 0015.
Below is the code that I have. It works well but its the zero thing I can't
figure out.
Dim Check As String
Dim lngLastRecordNo As Long
Dim lngPos As Long
Check = True
'go to last record
DoCmd.GoToRecord acActiveDataObject, , acLast
' update file
lngLastRecordNo = Me.CurrentRecord
DoCmd.GoToRecord acActiveDataObject, , acFirst
' Outer loop
Do
' Innerloop
' Set repetitions
For lngPos = 1 To Len(Me.FileNumber) Step 1
If Mid(Me.FileNumber, lngPos, 1) >= 0 And Mid(Me.FileNumber,
lngPos, 1) <= 9 Then
'found start of numbers
Me.FileLetter = Left(Me.FileNumber, lngPos - 1)
Me.FileNo = CLng(Mid(Me.FileNumber, lngPos))
'have finished for this one
Exit For
Else
'a letter get next chr
End If
Next lngPos
'this is how we exit when all records have be done
If Me.CurrentRecord = lngLastRecordNo Then Exit Do
DoCmd.GoToRecord acActiveDataObject, , acNext
'we never get to true we exit when all records have been visited
Loop Until Check = False
Can anyone see what needs to be added or changed?
Thanks for any help given.
*** John