Need Help

R

Ron

I created a datbase and forms. On the form i have to have a number field
called ceertificate number. This number is used to identify each record
created. It is currently an autonumber field. I would like to have this field
generate a new number by using a button, which will insert the number into
that field. Is there a way to do this?
 
D

doco

I think this will work...

Private Sub CommandButton_Click()
Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset(TableName, dbOpenSnapshot)

rs.MoveLast
Me.CertificateNumber.Value = rs.RecordCount + 1

Set rs = Nothing

End Sub

But AutoNumber does this anyway....
This is an oversimplification and would give a problem if the recordset was
empty to start but you should get the idea.

doco
 
Top