Raghav Chamadiya
New Member
- Joined
- May 31, 2020
- Messages
- 13
- Office Version
- 2016
- Platform
- Windows
So, I have a userform and a database file, the format of the invoice numbers(which act like unique serial numbers) in the database goes like 001/2020, 002/2020, 003/2020 and so on.
With the help of Userform_Initialize, I am auto populating the invoice field in my userform. So if last invoice is 008/2020, the invoice in form will show as 009/2020.
The code to do that is:
where lastInvoice is the Invoice number in the last used row in database, this is working fine.
The problem now is that sometimes users need to change the invoice numbers to the format xxx-A/2020, xxx-B/2020, and so on. xxx can be any number which is getting auto generated.
So when they add this A, B, C, my code stops calculating the invoice number properly.
Also they need not add the A, B, C every time. So, in database it can xxx/year or xxx-A/year and so on
Please help
With the help of Userform_Initialize, I am auto populating the invoice field in my userform. So if last invoice is 008/2020, the invoice in form will show as 009/2020.
The code to do that is:
VBA Code:
Me.txtInvoice.Value = Format(Int(Left(lastInvoice, 3)) + 1, "000") & "/" & current_year
where lastInvoice is the Invoice number in the last used row in database, this is working fine.
The problem now is that sometimes users need to change the invoice numbers to the format xxx-A/2020, xxx-B/2020, and so on. xxx can be any number which is getting auto generated.
So when they add this A, B, C, my code stops calculating the invoice number properly.
Also they need not add the A, B, C every time. So, in database it can xxx/year or xxx-A/year and so on
Please help