New entry button DMax

Ean James

Registered User.
Local time
Today, 17:54
Joined
Nov 9, 2005
Messages
14
Hello peeps!

Just someone advice if I can!

I have a table that contains student details:

StudentNo
Surname
Forename

I have created a form to add students to this table but I need a button that will read the highest StudentNo and then add one, putting the new stundent number in the form in a new record?

How can I go about doing this? Can it be done using a macro or do I need to use VBA??? I have been told that I would need to use the DMax function but I dont know VBA.

Thanks in advance for all your help
 
If this is shared system, AND you hold the new value to long, it could be duplicated. So for what you are discribing timing is critical. There are better ways to do it, like use an autonumber field, but I assuming at this point it is to late to try that. For the method you discribe it is basically this.
Run DMAX("columnname","tablename","any criteria if required (optional)")
Add 1 to returned value
Save new record.

Now you could in the fields default value use =DMAX(yada) + 1
and handle it all in one statment (given it is numeric, etc.)
But this would be bad if my first sentence is true.
If you want to go this road, it might be better to assign the value on the before update event (or something like that right before the actual insert) so the chances of duplication are reduced.
 
use the below

=dmax("[FieldName]","[TableName]")
 
Thank you very much for your replys!

Where would I find default value?

Thanks again :D
 
it ok I found it, thanks very much 4 your help, FoFa, KeithG
 

Users who are viewing this thread

Back
Top Bottom