Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create an Number increment on the form

Status
Not open for further replies.

axslearnr

Technical User
Apr 1, 2004
78
US
Hi
I have a employee table which has empid, empname, empcity etc. empid is an autonumber and starts from 1.

I need an number field for empid in the table so I can start the numbers from 1001 and increment by 1. I need to display that field on a form where it should display the number without entering like Autonumber.

How to do that?

Pls let me know

thanks


 
He axlearnr

I have an invoicing form in which I have an ADD button to add a new invoice record. On this form I have a field named [Invno], data type integer. The underlying table is named tblINVOICE.

In the OnClick event of the ADD button I have this line to find the last invoice number used, increment it by 1 and put the value in the [Invno] field.

Me![Invno] = DMax("[Invno]", "[tblINVOICE]") + 1

works a treat!

Hope this helps

Tel
 
Oh, I forgot to say that before putting that line of code in the ADD button, simply type in the starting number in the last existing record (eg 1000) so that when you then add new records they will be number 1001, 1002 etc.

Tel
 
Hi
Thansk for your reply. I dont have a button on my from. I just use the normal form. what even should I use ?

Pls let me know

thank you
 
Hi Axslearnr

I suppose you could use the BeforeInsert event (in your form properties). This event occurs when the user types the first character in a new record, but before the record is actually created. So if you use that, it will increment the sequence number as soon as you start to fill in data. Although, if I were you, I would still prefer to use an ADD button.

Tel
 
First, is this number important? Is it merely a unique record identifier? Does it matter TO YOU, not the system, if there are missing numbers?

If this is merly an identifier, just use autonumber. Search this site for starting autonumber to number other than one. It is not difficult and takes advantage of the built in codes Access has.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top