Hello,
I'm creating a Project ID and I'm having some trouble getting VBA to respond to correctly. My Project ID has to have 4 digits, so I'm taking the Autonumber ID that Access creates, and adding 0's before depending on how many digits it is.
Here's the code I'm using:
If it is single digit (i.e. <10), it adds the three 0's. However, once it doesn't recognize that it is between 9 and 100, and still adds three 0's. Is there something wrong with my code here? After I wrote this I understood that I could use Len(), but I'd still like to know where I went wrong.
Thanks
Robin
I'm creating a Project ID and I'm having some trouble getting VBA to respond to correctly. My Project ID has to have 4 digits, so I'm taking the Autonumber ID that Access creates, and adding 0's before depending on how many digits it is.
Here's the code I'm using:
Code:
iTempID = Me.ID.Value If iTempID > 999 Then iTempID = iTempID If 99 < iTempID < 1000 Then iTempID = "0" & iTempID If 9 < iTempID < 100 Then iTempID = "00" & iTempID If 10 > iTempID Then iTempID = "000" & iTempID Me.ProjectID.Value = iTempID
Thanks
Robin
Comment