Unique Reference Number

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
 
P

PC Datasheet

I suggest you keep autonumber!

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

John Vinson

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]
 

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

Similar Threads

Excel Need Countifs Formula Help 0
One-to-one relationship 2
Invoicing database 1
Ranking of Topics in Access 1
Unique number 1
Design Question 5
Connect Tables? I have too many fields 1
Database relations 1

Top