F
Fay Yocum
I have the following code in a textbox AfterUpdate event.
Private Sub txtTimeEnd_AfterUpdate()
Dim NewID As String
Dim OldID As String
OldID = Nz(DMax("Right(txtClassNum,3)", "tblSession",
"left(txtClassNum,1)= (txtClassID)"), "000")
NewID = Format(txtClassID) & "-" & Format(Right(OldID, 3) + 1, "000")
Me.txtClassNum = NewID
End Sub
It almost works. It formats almost correctly. For example it gives me 5-001.
But there is already a 5-001 so it isn't adding correctly. I now have three
5-001. What am I missing here?
Also I see another issue. the txtClassID will become greater that a single
digit number. So how should I change the code
"left(txtClassNum,1)= (txtClassID)") when I don't know how many digits will
comprise the txtClassID?
Thank you for your assistance. I hope you have a great week.
Fay
Private Sub txtTimeEnd_AfterUpdate()
Dim NewID As String
Dim OldID As String
OldID = Nz(DMax("Right(txtClassNum,3)", "tblSession",
"left(txtClassNum,1)= (txtClassID)"), "000")
NewID = Format(txtClassID) & "-" & Format(Right(OldID, 3) + 1, "000")
Me.txtClassNum = NewID
End Sub
It almost works. It formats almost correctly. For example it gives me 5-001.
But there is already a 5-001 so it isn't adding correctly. I now have three
5-001. What am I missing here?
Also I see another issue. the txtClassID will become greater that a single
digit number. So how should I change the code
"left(txtClassNum,1)= (txtClassID)") when I don't know how many digits will
comprise the txtClassID?
Thank you for your assistance. I hope you have a great week.
Fay