By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,101 Members | 1,335 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,101 IT Pros & Developers. It's quick & easy.

Autonumber generator

P: 22
Hi

I am trying to set up a small database for Horse Racing. I need to keep a database listing the details found in the racecard. The database will be used in to feed a caption generator which displays results, betting, racetitles etc over the CCTV on the racecourse. I am a complete novice and I am trying to find a way to create a autonumber generator for each horse in a race. The race will have it's own table but it's rather time consuming to keep putting in the number of the horse when it could be down automatically each time I save a record. I don't want to use autonumber in case I wan't to delete a record. I have scanned lots of sites and the propose using the DLast function in the before update properties of the form. Can someone give me a hand with the code. The Table is RunnersRace(Race No.) and the field is HorseNumber.

Thanks for any help
Frank Leggett
Oct 19 '06 #1
Share this Question
Share on Google+
8 Replies


Expert 5K+
P: 8,434
...I don't want to use autonumber in case I wan't to delete a record...
Is it really that big an issue if deleting a record leaves a "hole" in the numbers?
Oct 19 '06 #2

MMcCarthy
Expert Mod 10K+
P: 14,534
Use DMax instead of DLast

In the control on the form containing the Horse Number Field go to the properties and in the Default Property put the following:

=DMax("[HorseNumber]","RunnersRace")+1

Every time you add a new record the number will be generated automatically.

I'm concerned about using RunnersRace(Race No.) as a table name and have changed it to just RunnersRace.

Hi

I am trying to set up a small database for Horse Racing. I need to keep a database listing the details found in the racecard. The database will be used in to feed a caption generator which displays results, betting, racetitles etc over the CCTV on the racecourse. I am a complete novice and I am trying to find a way to create a autonumber generator for each horse in a race. The race will have it's own table but it's rather time consuming to keep putting in the number of the horse when it could be down automatically each time I save a record. I don't want to use autonumber in case I wan't to delete a record. I have scanned lots of sites and the propose using the DLast function in the before update properties of the form. Can someone give me a hand with the code. The Table is RunnersRace(Race No.) and the field is HorseNumber.

Thanks for any help
Frank Leggett
Oct 20 '06 #3

P: 22
Thanks for you replys. I need to add the raceno. after the table name as there is between 6 and 8 races for there needs to be a table for each one. I will try this out today. Thanks again

Frank
Oct 20 '06 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
If you need to add it don't use brackets and full stops

Try

RunnersRace_RaceNo

Thanks for you replys. I need to add the raceno. after the table name as there is between 6 and 8 races for there needs to be a table for each one. I will try this out today. Thanks again

Frank
Oct 20 '06 #5

P: 22
Sorry to bother but in what control on the properties in the form do I put the statement =DMax("[HorseNumber]","RunnersRace")+1

Frank
Oct 20 '06 #6

MMcCarthy
Expert Mod 10K+
P: 14,534
Its no bother Frank

Go to the design of the form

Right Click on the HorseNumber Field and click on properties in the list.

This will give you all the properties for this field

In the Data Tab go down to Default Value, this is where you want to put it.

Sorry to bother but in what control on the properties in the form do I put the statement =DMax("[HorseNumber]","RunnersRace")+1

Frank
Oct 20 '06 #7

P: 22
Thanks again for your help it works fine. Just a small point this process means I have to intially put a number into the field for it to increment is there a way for the first record to automatically start with "1"

Thanks again for all your posts.
Frank
Oct 20 '06 #8

MMcCarthy
Expert Mod 10K+
P: 14,534
=NZ(DMax("[NormalHours]","Table1")+1,1)



Thanks again for your help it works fine. Just a small point this process means I have to intially put a number into the field for it to increment is there a way for the first record to automatically start with "1"

Thanks again for all your posts.
Frank
Oct 20 '06 #9

Post your reply

Sign in to post your reply or Sign up for a free account.