Create function of a autonumber on primary key set as text?

Takstein

Registered User.
Local time
Yesterday, 12:39
Joined
Jan 31, 2007
Messages
54
Hi

i am creating a form where i am adding alot of posts, and now the primary key is set to be a text of 6 digits.

I would like this input to be more like an autonumber tho, but stil maintain the text primary key.

(Silly question) is this possible? maybe by using the last value+1?

Hope any of you guys can help me ( i dont know much about VBA)



Cheers, Takstein
 
Takstein said:
Hi

i am creating a form where i am adding alot of posts, and now the primary key is set to be a text of 6 digits.

I would like this input to be more like an autonumber tho, but stil maintain the text primary key.

(Silly question) is this possible? maybe by using the last value+1?

Hope any of you guys can help me ( i dont know much about VBA)



Cheers, Takstein


Just to clearify, i want every new number to increment when i add new posts...
 
Hi Takstein,

i do it using dmax function
Text294.Value = DMax("SN", "tbl_main_data") + 1
it works fine.
 
Why on earth are you storing a number as a text field?
 
Hi Takstein,

only use DMAX if the database is single user otherwise it is possible (and I have seen it happen) where the same number is generated twice.
There was a post on this topic a couple of weeks ago.
 
Last edited:
Dennisk said:
Hi Takstein,

only use DMAX if the database is single user otherwise it is possible (and I have seen it happen) where the same number is generated twice.
There was a post on this topic a couple of weeks ago.
You can minimise this risk by calculating the number only when the file is saved. Then set the number to Indexed, No Duplicates and trap the error if a duplicate is created.
 
Thanks guys!!

made it work now..


I dont really know why i stored it as a text field, but i am gona have severeal users on this database so i might change it to an autonumber..


Anyways...

Cheers!
 

Users who are viewing this thread

Back
Top Bottom