Familia Roca
New member
- Local time
- Today, 01:50
- Joined
- Aug 21, 2024
- Messages
- 1
I am having such a hard time trying to get this custom sequential Number. Please help!
The first Part gets the two digits from the current year, the middle part gets the max number and the last part the first letter of the value.
My control is a box with textbox short text datatype, but I cannot get the middle portion to work. The intended result needs to be something like 24-008763-S , 24-008764-N, or 24-008765-T in order to have every year a new number and or the middle portion resets to 0.
I have a Autonumber ID already. This is just for Displaying on forms and reports. The Student Type is entered after other fields have been entered, so the code goes on the save event.
Thank you so much for your help.
this is what I have come up with so far:
on save
Dim StudentNo As Long
Me.StudentNo.Value = Right(Year(Date), 2) & "-" & Format(Nz(DMax("Val(Mid(StudentNo,2))", "StudentsQB") + 1, "000000")) & "-" & Left(Me.StudentType.Value, 1)
or
'Me.StudentNo.Value = Right(Year(Date), 2) & "-" & Format(Nz(DMax("Val(Mid(StudentNo,2))", "StudentsQB") + 1, "000000") & "-" & Left(Me.StudentType.Value, 1))
The first Part gets the two digits from the current year, the middle part gets the max number and the last part the first letter of the value.
My control is a box with textbox short text datatype, but I cannot get the middle portion to work. The intended result needs to be something like 24-008763-S , 24-008764-N, or 24-008765-T in order to have every year a new number and or the middle portion resets to 0.
I have a Autonumber ID already. This is just for Displaying on forms and reports. The Student Type is entered after other fields have been entered, so the code goes on the save event.
Thank you so much for your help.
this is what I have come up with so far:
on save
Dim StudentNo As Long
Me.StudentNo.Value = Right(Year(Date), 2) & "-" & Format(Nz(DMax("Val(Mid(StudentNo,2))", "StudentsQB") + 1, "000000")) & "-" & Left(Me.StudentType.Value, 1)
or
'Me.StudentNo.Value = Right(Year(Date), 2) & "-" & Format(Nz(DMax("Val(Mid(StudentNo,2))", "StudentsQB") + 1, "000000") & "-" & Left(Me.StudentType.Value, 1))