Solved How to increment a number with VBA (1 Viewer)

nector

Member
Local time
Today, 14:43
Joined
Jan 21, 2020
Messages
412
Dear all

I'm now screwed out here :

I want to increment a number in format

(1) 0000010 to 99
(2) 0000100 to 199
(5) 0000200 to 299
ETC

I have tried to use the primary key but its considering the zeros


Code:
Private Sub itemTyCd_AfterUpdate()
Me.itemCd = Ctri("000000") & Me.ProductID
End Sub
 

CJ_London

Super Moderator
Staff member
Local time
Today, 12:43
Joined
Feb 19, 2013
Messages
16,774
why not just use the format function?

format(productid,”0000000”)

will add the preceding zero’s and change it from a Number to text
 

KitaYama

Well-known member
Local time
Today, 20:43
Joined
Jan 6, 2022
Messages
1,654
Change this according to your controls on the form.

Code:
Function Test(myString As String) As String
        
    Test = Right("00000000" & Val(myString) + 99, 7)
    
End Function
 

Users who are viewing this thread

Top Bottom