how to return preceding zeros

doylie

Registered User.
Local time
Today, 17:12
Joined
Jul 25, 2002
Messages
22
Function ChangeDate(adate As Long) As Long
Dim t As Integer
Dim num As Long
Dim num2 As Long
Dim max As Object
Dim snumber As Object
Set dbcurrent = currentdb()
num = Left(adate, 3)
num2 = Right(adate, 4)

For t = 0 To t = dbcurrent.Tabledefs("Table1").RecordCount
If num >= 100 Then
adate = updatedate1(num, num2)
End If
adate = adate
Next
ChangeDate = adate
End Function

Function updatedate(num As Long, num2 As Long) As Long

Select Case [num]
Case 100
num = Left("00", 2) & Left(num2, 4)
Case 101
num = Left("01", 2) & Left(num2, 4)
Case 102
num = Left("02", 2) & Left(num2, 4)
End Select
updatedate = Left(num, 6)

End Function

This is the code I have written to try and update a series of dates which I have had downloaded from a legacy system into access. The year 2000 dates and later are preceded with a 1 so as to be year 2000 compliant. eg. 1020510 is 10/05/02 when I run an update query with this function it is returns 2510 as the preceding zeros are omitted, is there any function I can insert which will prevent this from happening.:) Cheers
 
Hello
I could be barking up the wrong tree here but if you are trying to spilt the number up and return each part to a numeric variable you will lose the leading Zeros, my suggestion is you try a string instead.



Chris
 

Users who are viewing this thread

Back
Top Bottom