Form Auto Numbering

  • Thread starter rollover99 via AccessMonster.com
  • Start date
R

rollover99 via AccessMonster.com

I am looking for something within my form that will add a number to the
highest number in the table for every new record that will be used as an
identifier. Autonum is not a reliable way of doing this. I am trying to
have the numbers auto enter for a new record and save with the record into
the master table.


I have tried placing the formula
=DMax("id#","qcpc master")+1
in the default value for the bound text box QCPCID, but this is not adding
the new record number.
 
A

Allen Browne

Use the BeforeUpdate event of the *form* (not the event of a control), to do
that:

Private Sub Form_BeforeUpdate(Cancel As Integer
If IsNull(Me.[id#]) Then
Me.[id#] = Nz(DMax("[id#]","[qcpc master]"), 0) + 1
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top