I am trying to add a button to a form that will automatically create a new entry with sequential numbering. Currently the numbering function is on the table "Client TP Tracker" in the field TPID. Once the button is clicked, a new form should be created and the new TPID number should be the next one available. The code I've tried is this:
I'm getting a Compile error: Method or data member not found over the Me.TPID section right before the End If.
I'm not sure what I have wrong here.
Code:
Private Sub Command167_Click()
Dim TPID As Variant
Dim strMax As String
Dim IngNewNum As Long
Dim OpenDate As Variant
'Copy fields to variables
TPID = Me!TPID.Value
'Go to a new record
DoCmd.GoToRecord , , acNewRec
'Reverse the process and plug old values into new record
Me!TPID.Value = DMax("TPID", "Client TP Tracker")
Me!OpenDate = Date
If Me.NewRecord = True Then
strMax = Nz(DMax("TPID", "Client TP Tracker"), "CLT-00000")
IngNewNum = CLng(Right(strMax, 5)) + 1
Me.TPID = "CLT-" & Format(IngNewNum, "00000")
End If
I'm getting a Compile error: Method or data member not found over the Me.TPID section right before the End If.
I'm not sure what I have wrong here.