Increment of a specific number for a registration

  • Thread starter Thread starter Ramona
  • Start date Start date
R

Ramona

Guest
PLease help me with this one.
I have a table and some fields defined:

ID (autonumber)
Data (data)
Description of the document (text)
Registration number (number)

I want for the registration number to create an expression, perhaps, to define it automatic when i enter a new file, and that number should start from 12 .

I am new with Access and perhaps somebody can give me a help with this situation.

Thanks,
Ramona
 
I use the following code to create the next new delivery note number, it uses the DMax() function. Basically it looks at the orders table and the Max number then adds 1 to it. The code is attached to the OnClick of a button but you can use it wherever

Code:
On Error GoTo lerror

Dim r As Recordset, db As Database, x As Double
Set db = CurrentDb
Set r = db.OpenRecordset("tblOrders")

x = DMax("[DeliveryNoteNo]", "tblorders") + 1

Me.DeliveryNoteNo = x

lerrorexit:
   Exit Sub
   
lerror:
   MsgBox Err.Description
   GoTo lerrorexit

Enter the first number yourself (12) then the next will be 13 etc etc

Col
 
So....I put the code you gave me into the code area of the db, after that i entered a file and gave the number myself (12) hoping that the next file will increase the number automatic....but it didn't.

Where did i go wrong?

please tell me if i should have made any changes in the code you wrote.

10xs,
ramona
 
Post your Db and I'll have a look.

I have the code in the OnClick of a button on a form. Obviously, you'll need to change the field names in the code to match yours.

Col
 
The random number i want to be increased automatic is at "registration number" field.
I attached the file.


HAPPY NEW YEAR!! :)
10xs,
Ramona
 

Attachments

Here you go. I've added a button and amended the code so that it works.

Col
 

Attachments

Increment alphanumeric field

I have the same concern on my dbase.

I created a field named "Policy Number" in one table.

The idea is the same as that of Ramona's, but the problem is, the field type is ALPHANUMERIC. (Example: TSI-PCA-05-1000111RA).

Would it be possible to automatically increment the underlined?

Many thanks.

Sheila
 
Last edited:

Users who are viewing this thread

Back
Top Bottom