You are saving the ID as soon as you generate it. The control source should be bound to GenPersonID so it shows the existing record rather than generating a new one.
I would normally not generate the ID until the Form's BeforeUpdate event. If the user needs to see the generated value, you'll need to do it sooner or give the user a save button to force a save and generate the ID without moving to a new record.
Sir
I cannot get it to work. I have a button on my form with the follwing
Me.Increment = Nz(DMax("[Increment]", "Contacts", "Left([LastName],1) = '" & Left(Me.LastName, 1) & "'"), 0) + 1
Me.Dirty = False
End Sub
It does nothing. But if i take the follwing
=Nz(DMax("[Increment]","Contacts"),0)+1
It works but obviously it is not taking the next initial and then incrementing. It just increments to the next number irrespective of the Alpha.
Just to recap
1. I have a field in my table called Increment (number longer integer0
2.I have a control on my form ( =Left([LastName],1) & [Increment])
3. I also have a hidden control named Increment bound to Increment in my table.
So i think the last part is causing me stress for two days.
Can i not use the dmax function somewhere else.
I even tried the following
Dim strAbbrName As String
strAbbrName = Left(Me.FirstName, 1) + Left(Me.LastName, 3)
Me.GenPersonID = Nz(DMax("GenPersonID", "Contacts*", "Left(FirstName, 1) & Left(LastName, 3) = '" & strAbbrName & "'"), 0) + 1
DoCmd.RunCommand acCmdSaveRecord
End Sub
Still no increment. just the first letter in ClientCode.