Unique Reference Number

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi Everybody,

I need to allocate a unique reference number to new students in my school.

For the purpose of the database, I was using the Autonumber facility,
but I'd like to use the students' unique reference number instead.

I'd like the table to count the number of records and then add 1 to it.

Or

Find the highest number in the field and add 1 to it.

Any ideas greatly appreciated,

Jeff
 
I suggest you keep autonumber!

However you can use:
DMax("[ReferenceNumber]","TblStudent") + 1
 
Hi Everybody,

I need to allocate a unique reference number to new students in my school.

For the purpose of the database, I was using the Autonumber facility,
but I'd like to use the students' unique reference number instead.

I'd like the table to count the number of records and then add 1 to it.

Or

Find the highest number in the field and add 1 to it.

Do your data entry using a Form (only forms have the appropriate
events, table datasheets don't).

In the Form's BeforeInsert event put code like

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!txtReferenceNo = NZ(DMax("[ReferenceNo]", "[Students]")) + 1
End Sub

where ReferenceNo is the fieldname, Students the table name, and
txtReferenceNo the name of the form control.

John W. Vinson[MVP]
 
Back
Top