AutoNumbers (and their usage)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • accountant
    New Member
    • Oct 2007
    • 5

    AutoNumbers (and their usage)

    hello ,

    1. How can I serialize numbers in Access , what I mean is A0201,A0202 ,

    2. <Question removed as split to thread Counting in a Query>


    thank you very much.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32666

    #2
    Originally posted by accountant
    hello,

    1. How can I serialize numbers in Access , what I mean is A0201,A0202 ,

    2. <Question removed as split to thread Counting in a Query>


    thank you very much.
    This depends on what you ACTUALLY want.
    If you need each new record to have a different number from any used before, then you can use an AutoNumber field. When that has been created you will need to edit this field to include that value (formatted to four digits with an "A" at the front). This must be stored in another field. An AutoNumber is just that, a number.
    What you need to know about AutoNumbers :
    They are never reused (in the normal flow of usage).

    If however, you must have the very next number in ALL circumstances, then adding one to the maximum currently found in the table will get the number part that you're after. Same formatting as before.

    In truth, there is too little information in the question to go further. It all depends on so many things that only you know at the moment. What does this idea fit into? Is it supposed to be working within a query or is code allowed? Over to you.

    Comment

    • accountant
      New Member
      • Oct 2007
      • 5

      #3
      Originally posted by NeoPa
      What does this idea fit into? Is it supposed to be working within a query or is code allowed? Over to you.
      I am supposed to give people an ID number, the first person ID number is supposed to be A0201 , the second person's ID number should be A0202 and so on.

      Thank you very much for your time, I truly appreciate it.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32666

        #4
        Originally posted by accountant
        I am supposed to give people an ID number, the first person ID number is supposed to be A0201 , the second person's ID number should be A0202 and so on.

        Thank you very much for your time, I truly appreciate it.
        I can see from the flag and your profile that you're from Dubai so communicating in English may be a bit harder than for those of us that speak it naturally, but I need the information asked for in the question.
        I get that you need to assign these codes to different records in your table. What I don't get is how you're thinking of doing this. What have you tried? How is the database to be used? I really need a picture of what it needs to fit into. I've already given the basic concept of how it can be done - until I have a better understanding of what you're trying to do I can't help further.

        Comment

        • nico5038
          Recognized Expert Specialist
          • Nov 2006
          • 3080

          #5
          Basically you need to split the code into the "A" and the number in separate fields in that table. This will prevent future trouble when e.g. the A9999 is reached...

          For this "coded number" you need to use this construction to get the next "number":
          Code: ( text )

          1.
          "A" & Right("0000" & (Val(DMAX("Mid( yourcodefield,2 )","YourTable") +1),4)



          It gets the Max of the number part, thus multiple ranges (A0000-A9999,B000-B9999) won't be possible!
          The Max is incremented and formatted to display leading zero's and the "A" is placed infront of this.

          Let me know when you need further assistance.

          Nic;o)

          Comment

          Working...