Autonumber generator

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • frankleggett
    New Member
    • Oct 2006
    • 22

    #1

    Autonumber generator

    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
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by frankleggett
    ...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?

    Comment

    • MMcCarthy
      Recognized Expert MVP
      • Aug 2006
      • 14387

      #3
      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.

      Originally posted by frankleggett
      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

      Comment

      • frankleggett
        New Member
        • Oct 2006
        • 22

        #4
        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

        Comment

        • MMcCarthy
          Recognized Expert MVP
          • Aug 2006
          • 14387

          #5
          If you need to add it don't use brackets and full stops

          Try

          RunnersRace_Rac eNo

          Originally posted by frankleggett
          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

          Comment

          • frankleggett
            New Member
            • Oct 2006
            • 22

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

            Frank

            Comment

            • MMcCarthy
              Recognized Expert MVP
              • Aug 2006
              • 14387

              #7
              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.

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

              Frank

              Comment

              • frankleggett
                New Member
                • Oct 2006
                • 22

                #8
                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

                Comment

                • MMcCarthy
                  Recognized Expert MVP
                  • Aug 2006
                  • 14387

                  #9
                  =NZ(DMax("[NormalHours]","Table1")+1,1 )



                  Originally posted by frankleggett
                  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

                  Comment

                  Working...