I'm trying to get a form to increment a field when someone enters a new record for a property. So for below, on the last one I want the code to fill in "3" for the UnitID when a person enters that record.
I tried using the code suggested in an earlier answer about how to do this on the "BeforeInsert". But it keeps bombing. I know it's something simple, but I'm not seeing the problem.
Here's the code I used:
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!UnitId = Nz(DMax("[UnitID]", "tblVacyUnits", "[UnitID]=" & Me!UnitId), 0) + 1
Me.Dirty = False
Got the error: Syntax error (missing operator in query exression "[UnitID]="
when I do the above.
Please let me know what I'm doing wrong.