Auto Incrementing Numbers!

vdanelia

Registered User.
Local time
Today, 05:08
Joined
Jan 29, 2011
Messages
215
Hello Friends
I'm making an auto incrementing numbers for my field (In Table Default Value, That to be filled automatically for a new record) I tried this code, but getting errors... Please help what I'm doing incorrectly..
=DCount("ID","DATA","ID <=" & [ID]) It's working from unbound text box, but i need it to put in the Default Value of the field.

And How to add my format for this code too for example: SSD00001, SSD00002, SSD00003 and so on.

Thank you in Advanced
 
What field type is ID? is it an autonumber field?
If it is, this can't work on a record that hasn't been created yet.
 
Are you sure you don't want DMax():
Code:
=Nz(DCount("ID","DATA[URL="http://www.access-programmers.co.uk/forums/showthread.php?t=206309#"][COLOR=darkgreen][/COLOR][/URL]"), 0) + 1
Should go in the Default Value property of the textbox.

Format:
Code:
"SSD"00000
 
Hello! Thank You for the reply, but
Getting Error!
When I put the code in the default value of the table
 
Your not going to be able to put that code in the default value of the field you will need to put it in the On Current event of your Form
 
...you will also want to put a test in your procedure to check if that filed already hold a value so as to not overwrite it.
 
Last edited:
Hello! Thank You for the reply, but
Getting Error!
When I put the code in the default value of the table

vbaInet said default of TEXTBOX, and NOT field in table. You can't use a default in the table like that.
 
On My Forms Current Event I'm already using another VBA Code, How can I use then... I'm Comfused
 
Any event on a form can do any number of functions it is simply a matter of using logical (if Then) tests to determine which ones should be run and in which order they should be run.
 
I tested Every variant, but not working correctly it is not synchronized with main table ID
 

Users who are viewing this thread

Back
Top Bottom