Get a Jumpstart with our Sample Apps
Results 1 to 23 of 23

Thread: auto increment

  1. #1
    Member
    Real Name
    Richard Vulpis
    Join Date
    Feb 2003
    Posts
    20

    Default auto increment

    in my field rules i selected auto increment
    how do i start the the number i want
    this is the starting # 06-1000

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,695

    Default

    Quote Originally Posted by richie V
    in my field rules i selected auto increment
    how do i start the the number i want
    this is the starting # 06-1000
    The documentation for later versions still applies to your situation.


    Creating an Auto-Increment Field

    1. Display the Tables/Sets tab of the Control Panel.
    2. Select the table that will contain the auto-increment field.
    3. Select Design > Field Rules.
    4. Select the field that will be auto-numbered from the drop-down list at top left.
    5. On the Field Types tab under Extended field types select Auto increment.

    6. Display the Data Entry tab.
    7. In the Required section select "Always required".
    8. Check Auto advance after field filled.
    9. For Default mode select "Simple default expression".
    10. For Default value set the initial value of the series. If this is a character field, put quotes around the value (e.g. 00001 for a numeric field and "00001" for a character field).
    11. Put .T. into the Skip field.
    12. Click Save and exit from the Field Rules editor.

  3. #3
    Member
    Real Name
    Richard Vulpis
    Join Date
    Feb 2003
    Posts
    20

    Default

    i did exactly that
    when i have auto increment on it don't work
    if i have auto increment off it enters the defalt value

  4. #4
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,298

    Default Example for Richard

    Richard,

    Here's an example, using A5v7. Will run under A5v5 or A5v6, too.

    Compare how this is working, and how it's set up, with what you've been doing.

    -- tom

  5. #5
    Member Robin Hoare's Avatar
    Real Name
    Robin Hoare
    Join Date
    Dec 2005
    Location
    Rawene, a small rural township in the Far North of New Zealand
    Posts
    157

    Default

    I've been having a bit of trouble with autoincrement fields, too.

    My field is numerical (4 digit) and I specified a default of 0001 (no ""s)

    However I got a zero for the first field ID.

    I was working with the recommended "Check auto advance after field filled" and did not check "at start of data entry"

    Now I have changed over to Tom's method, which is the reverse: no "Check auto advance..." but checking "at start..."

    And it works! The first field ID is now 1 as it should be.

    I wonder why.

    Robin

  6. #6
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,695

    Default

    Quote Originally Posted by Robin Hoare
    My field is numerical (4 digit) and I specified a default of 0001 (no ""s)
    Probably had a problem (or more precisely unexpected behavior) because 0001 (no ""s) is not numeric.

  7. #7
    Member Robin Hoare's Avatar
    Real Name
    Robin Hoare
    Join Date
    Dec 2005
    Location
    Rawene, a small rural township in the Far North of New Zealand
    Posts
    157

    Default

    I did try the simple 1 too, same results! (ie. without the leading zeros)

    Robin

  8. #8
    Member
    Real Name
    Arthur H. Lieber
    Join Date
    Jun 2006
    Posts
    6

    Default Re: auto increment

    I have seen a great deal about creating auto-increment fields. I have a table with over 600 records. I just inserted a new field to give a unique identifier to each record. How do I make auto-increment work on records that are already created? Thanks! -- Arthur

  9. #9
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,695

    Default Re: auto increment

    Quote Originally Posted by civitas
    I have seen a great deal about creating auto-increment fields. I have a table with over 600 records. I just inserted a new field to give a unique identifier to each record. How do I make auto-increment work on records that are already created? Thanks! -- Arthur
    You don't. Temporarily remove the auto-increment designation, populate the field via an update operation, then reinstate the rule. The auto-increment is a data entry field rule, not something that can be applied retroactively to existing records.

  10. #10
    Member
    Real Name
    Arthur H. Lieber
    Join Date
    Jun 2006
    Posts
    6

    Default Re: auto increment

    Stan, thanks very much. That did the trick! -- Arthur

  11. #11
    Member
    Real Name
    Richard Connors
    Join Date
    Feb 2007
    Posts
    6

    Default Re: auto increment

    I have the same problem as Civitas. I’m moving an A4v8 set with a mother and two children, both of which are linked through the auto-incrementing ID field. This DB is at least ten years old and has 26620 mother records and over 15000 records in each of the children. Can’t get the auto-increment to work, and now I see why.

    I’m new to A5, am using v8, and not sure what you mean by your “populate” instruction to Covitas. Could you expand this for me?

  12. #12
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,695

    Default Re: auto increment

    Quote Originally Posted by Richard Connors View Post
    I have the same problem as Civitas. I’m moving an A4v8 set with a mother and two children, both of which are linked through the auto-incrementing ID field. This DB is at least ten years old and has 26620 mother records and over 15000 records in each of the children. Can’t get the auto-increment to work, and now I see why.

    I’m new to A5, am using v8, and not sure what you mean by your “populate” instruction to Covitas. Could you expand this for me?
    You can use an update operation to "populate" (modify, replace, etc) any user entered field with data of the appropriate data type. You first have to change the field from auto-increment to user entered, run the update, then change it back to auto-increment. I'm not sure what your exact need is. If you explain what you need to do I can advise more directly.

  13. #13
    Member
    Real Name
    Richard Connors
    Join Date
    Feb 2007
    Posts
    6

    Default Re: auto increment

    Oh, sorry. When I enter a new record into the mother, the ID field appears as 99000, no matter what I try. If I manually enter the value I want—26621—it reverts to 99000 anyway. I’ve followed all the alternative suggestions above and nothing works.

  14. #14
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,695

    Default Re: auto increment

    Quote Originally Posted by Richard Connors View Post
    Oh, sorry. When I enter a new record into the mother, the ID field appears as 99000, no matter what I try. If I manually enter the value I want—26621—it reverts to 99000 anyway. I’ve followed all the alternative suggestions above and nothing works.
    I believe the auto-increment behavior changed between A4 and A5 (any version). The machinery behind the auto_increment field will never increment to nor allow entry of a value less than the present "highest" value in the field. Since you are seeing the 99000, it seems there must be a 98999 value in your table somewhere. I would suggest that you open the main table in question (the parent of your set). Sort descending on the auto-increment field. Note the values you see.

    You are expecting to see 26620 as the highest value. Is this what you find?

  15. #15
    Member
    Real Name
    Arthur H. Lieber
    Join Date
    Jun 2006
    Posts
    6

    Default Re: auto increment

    Thanks so much! I really appreciate the help. -- Arthur

  16. #16
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,695

    Default Re: auto increment

    Quote Originally Posted by civitas View Post
    Thanks so much! I really appreciate the help. -- Arthur
    Please describe what you found so anyone who visits this post later might also be able to diagnose their issues.

  17. #17
    Member
    Real Name
    Richard Connors
    Join Date
    Feb 2007
    Posts
    6

    Default Re: auto increment

    Quote Originally Posted by Stan Mathews View Post
    You don't. Temporarily remove the auto-increment designation, populate the field via an update operation, then reinstate the rule. The auto-increment is a data entry field rule, not something that can be applied retroactively to existing records.
    I'm trying to move an A4v8 "client" file to A5v8. It has an ID field of 5 characters, the max value of which is 26670. No matter what I do, the value entered is 99000. I tried this suggestion of first removing the auto-increment designation and doing an update. Didn't work. I then manually entered three records with values 30000, 30001, and 30002, then re-established the auto-increment. That didn't make any difference either. Still enters 99000,

    I played with it a bit. Made the field 6 characters instead of 5, for example. Then the auto-increment entered the value 990000.

    Very frustrating. This file is way too big to lose. I need some major help here, please.

  18. #18
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,298

    Default Re: auto increment

    I've only seen this when my ID field had unexpected data in it. If it were me, I'd study the table to verify that the highest field value is only "26670".

    It's not clear from your post if the field is numeric or character type. If you can't solve this on your own, let us know which is applicable when you reply.

    -- tom

  19. #19
    Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,382

    Default Re: auto increment

    Richard

    Open a default browse for the table. Highlight the ID field, then from the menus - navigate - tools - field statistics. You should see something similar to what the attached image shows for Alphasports.

    Check the max value for that field.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  20. #20
    Member
    Real Name
    Richard Connors
    Join Date
    Feb 2007
    Posts
    6

    Default Re: auto increment

    Quote Originally Posted by Tom Cone Jr View Post
    I've only seen this when my ID field had unexpected data in it. If it were me, I'd study the table to verify that the highest field value is only "26670".

    It's not clear from your post if the field is numeric or character type. If you can't solve this on your own, let us know which is applicable when you reply.

    -- tom
    Interesting. It's a character field in both A4 and A5. When I sort that field in A4 it displays in strict numerical order--first record "1", last record "26670". When I sort the same field in A5 it shows the first or lowest record as "1", but the highest is "99". Because of some deleted records over the years, there is no record "999" and also there is no "9999". Apparently, the decimal placeholders, or zeros, didn't come thru the conversion properly. Record "00099" in A4 came through as "99000" in A5.

    How can I keep the zeros in their proper places?

  21. #21
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,298

    Default Re: auto increment

    Richard, what you describe suggests to me that the data type for the ID field in Alpha Four was numeric, and Alpha Five converted it to character. Did you append records from the Alpha four table, or did you just begin using a copy of the A4 dbf?

    In any case the answer to your original question is now clear. The "99 " sorts to the top of the list, and is being used by the autoinc field rule as expected.

    If you turn off the field rule you can define an "update" operation that will prepend leading zeros using an expression like this:

    padl(alltrim(ID), len(ID), "0")

    I caution you not to do this without making a safety backup copy of your data first. Many an update operation has gone awry and they're dang difficult to reverse. Run the update against a throw away copy of the table first, before running it against your real data.

    Once the field values have been zero filled you can then turn the autoinc field rule back on.

  22. #22
    Member
    Real Name
    Richard Connors
    Join Date
    Feb 2007
    Posts
    6

    Default Re: auto increment

    Quote Originally Posted by Tom Cone Jr View Post
    Richard, what you describe suggests to me that the data type for the ID field in Alpha Four was numeric, and Alpha Five converted it to character. Did you append records from the Alpha four table, or did you just begin using a copy of the A4 dbf?

    In any case the answer to your original question is now clear. The "99 " sorts to the top of the list, and is being used by the autoinc field rule as expected.

    If you turn off the field rule you can define an "update" operation that will prepend leading zeros using an expression like this:

    padl(alltrim(ID), len(ID), "0")
    Yes, this sounds right to me. Can you give me a little more detail about preparing the update? The genie doesn't seem to allow what I need to do.

  23. #23
    Member
    Real Name
    Richard Connors
    Join Date
    Feb 2007
    Posts
    6

    Default Re: auto increment

    OK, got it! Had to mess around with the indexes and not use the genie, but it worked! Thanks for everything.

    Richard

Similar Threads

  1. Auto Auto-Increment Field
    By Ken McEntee in forum Alpha Five Version 5
    Replies: 8
    Last Post: 05-12-2004, 01:12 PM
  2. Auto Increment Next Value
    By BRIAN GRAY in forum Alpha Five Version 5
    Replies: 1
    Last Post: 10-04-2003, 05:34 PM
  3. Auto Increment
    By Phil Gillenwater in forum Alpha Five Version 4
    Replies: 5
    Last Post: 07-27-2002, 06:02 AM
  4. Auto Increment
    By Don Barrett in forum Alpha Five Version 4
    Replies: 1
    Last Post: 06-07-2000, 08:25 PM
  5. Auto Increment
    By forskare in forum Alpha Five Version 4
    Replies: 6
    Last Post: 05-26-2000, 05:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •