Autonumber in groups of 10

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I want to create an autonumber field but have it go in groups of 10 such as
41770, 41780, 41790 etc rather than one number right after another. It woul
also be fine to create a field that isn't autonumber but automatically goes
up by 10 every time there is a new record created. Can someone help?

Thanks,
 
With Jet 4, you can specify the starting point and the increment. To be
executed in the Immediate (Debug) window, NOT in the query designer:



CurrentProject.Connection.Execute "CREATE TABLE toto555 ( tutu555
AUTOINCREMENT(1000, 10), titi555 TEXT(50) ) ; "


Hoping it may help,
Vanderghast, Access MVP
 
Put the following code in the "before insert" event. "RecordID" is the field
and "tble_hrs" is (obviously) the table!

Me!RecordID = DMax("[RecordID]", "[tble_hrs]") + 1

Hope it helps
 
Put the following code in the "before insert" event. "RecordID" is the field
and "tble_hrs" is (obviously) the table!

Me!RecordID = DMax("[RecordID]", "[tble_hrs]") + 10

Make sure you manually enter the appropriate number in the first record
otherwise it won't work.

Hope it helps
 
Queries are strictly for retrieval, not entry (I've always used them for
retrieval). I use forms for data entry (unless you are using a query as a
record source).

If you create a form for data entry,

Open the form in design view,
right click on the appropriate box, choose "properties" -> "events"
In the "before insert" event choose "event procedure"
Click on the "..."

Inser the following line into the procedure and change the field and table
names.

Me!RecordID = DMax("[FIELDNAME]", "[TABLENAME]") + 10

Save and exit

I suggest for the first record you manually enter the first ID and then
disable it (go to "properties" -> "data" and change "enabled" to "no"). When
you create a new record and enter information into another field, the new ID
number will be inserted automatically (the database will look for the highest
number and then add 10)

It should work. Let me know

ChuckW said:
Thanks for your help. I am a novice access user and am trying to figure out
how to do this. I this done through a query? I am used to doing queries in
design mode and sometimes going in and modifying the sql in the sql viewer
code. Can you give me a few steps on where to start with this process?

Thanks,
--
Chuck W


scubadiver said:
Put the following code in the "before insert" event. "RecordID" is the field
and "tble_hrs" is (obviously) the table!

Me!RecordID = DMax("[RecordID]", "[tble_hrs]") + 1

Hope it helps

ChuckW said:
Hi,

I want to create an autonumber field but have it go in groups of 10 such as
41770, 41780, 41790 etc rather than one number right after another. It woul
also be fine to create a field that isn't autonumber but automatically goes
up by 10 every time there is a new record created. Can someone help?

Thanks,
 
Thanks for your help. I am a novice access user and am trying to figure out
how to do this. I this done through a query? I am used to doing queries in
design mode and sometimes going in and modifying the sql in the sql viewer
code. Can you give me a few steps on where to start with this process?

Thanks,
--
Chuck W


scubadiver said:
Put the following code in the "before insert" event. "RecordID" is the field
and "tble_hrs" is (obviously) the table!

Me!RecordID = DMax("[RecordID]", "[tble_hrs]") + 1

Hope it helps

ChuckW said:
Hi,

I want to create an autonumber field but have it go in groups of 10 such as
41770, 41780, 41790 etc rather than one number right after another. It woul
also be fine to create a field that isn't autonumber but automatically goes
up by 10 every time there is a new record created. Can someone help?

Thanks,
 
that should be

Me!FIELDNAME = DMax("[FIELDNAME]", "[TABLENAME]") + 10



ChuckW said:
Thanks for your help. I am a novice access user and am trying to figure out
how to do this. I this done through a query? I am used to doing queries in
design mode and sometimes going in and modifying the sql in the sql viewer
code. Can you give me a few steps on where to start with this process?

Thanks,
--
Chuck W


scubadiver said:
Put the following code in the "before insert" event. "RecordID" is the field
and "tble_hrs" is (obviously) the table!

Me!RecordID = DMax("[RecordID]", "[tble_hrs]") + 1

Hope it helps

ChuckW said:
Hi,

I want to create an autonumber field but have it go in groups of 10 such as
41770, 41780, 41790 etc rather than one number right after another. It woul
also be fine to create a field that isn't autonumber but automatically goes
up by 10 every time there is a new record created. Can someone help?

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top