Here's the same code for an IDNumber defined as Numerical:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
If RecordsetClone.RecordCount = 0 Then
Me.IDNumber = 1
Else
Me.IDNumber = DMax("[IDNum]", "YourTableName") + 1
End If
End If
End Sub
How do I use dmax?
If RecordsetClone.RecordCount = 0 Then
Me.IDNumber = 1
Else
Me.IDNumber = DMax("[IDNum]", "YourTableName") + 1
Couple of questions, Mike375.
How /where are you using this?
=DMax("[NameNumber]","MainTable")
will return Null if there are no records in the table.
Because of this, if you use it when adding the first record, it'll error out with "Invalid use of Null" because you're trying to add one to a Null value.
And why are you answering Henley12's question, that was posted 4 months ago, when the question was answered in detail, the nest day?