Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Auto Increment Character Field

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Auto Increment Character Field

    I have a character field that I have been auto-incrementing for quite some time now. I started with 1 and it has worked well through some 30K records.

    For some reason, it stopped working and I cannot get it to go back to auto-incrementing.

    I tried the standard, "set default value" but it just returns "0000" as a value.

    I can change it to a numeric field and it works, but it screws up so many other things that rely on it being a character field, I just can't do it.

    I tried to copy the records into another table, rename the original and then rename the new table, but that did not work either.

    Any suggestions?

    #2
    RE: Auto Increment Character Field

    John

    There are a couple of possibilities.

    1. You got a value that is at the maximum for the size field that you have defined. Then it will roll over to 0000.

    2. The character value is not right justified within the field. Recently a message on the board pointed to a similar problem that another user was having and the solution was to eliminate the trailing spaces in the field. Of course all the records needed to be changed in the parent and any child records that are linked by that field.

    I'd open a browse with a few indentifying fields and the autoincrement field and sort descending on the auto increment. Look at the largest value that shown and/or see if there are any trailing spaces in the field.

    As always before making any changes, back up back up back up.

    Good luck.
    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.
    "Make it as simple as possible, but not simpler."
    Albert Einstein

    http://www.iadn.com/images/media/iadn_member.png

    Comment


      #3
      RE: Auto Increment Character Field

      Thanks for the advise.

      I also have found that I can use the increment function and make it a calculaed field in the rules. This seems to work as well, or am I missing something.

      Comment


        #4
        RE: Auto Increment Character Field

        John

        The increment function is relatively new. I'm not sure of the ramifications of using it in a calculated field.

        How did you solve the 0000 problem?
        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.
        "Make it as simple as possible, but not simpler."
        Albert Einstein

        http://www.iadn.com/images/media/iadn_member.png

        Comment


          #5
          RE: Auto Increment Character Field

          I solved the problem by isung the increment function.

          I made the field a calc field and increment(10000).
          the next record that I added was 10001, 10002 and so on.

          It seems to work.

          Thanks,

          Comment


            #6
            RE: Auto Increment Character Field

            In 4.5 I think almost noone used the autoincrement field, as it could very easily get out of synch. My understanding is that in V5, it is much better. But I have seen at least one post that they were still having problems with it.

            I still manually handle all my autoincrement fields - like
            nextcustomernumber
            nextinvoicenumber
            etc.

            here is a script, in field rules, in record events, in the onenter event:
            "nextinvoicenumber" is a table with one numeric field, and one record, although the field invoicenumber, in invoices, is a character field.


            trys=0
            on error goto isopen
            t1=table.open("nextinvoicenumber",FILE_RW_EXCLUSIVE)
            on error goto errors
            t1.change_begin()
            t1.nextinvoicenumber=t1.nextinvoicenumber + 1
            t1.change_end(.t.)
            t=table.get("invoices") 'or t=table.current()
            t.invoicenumber=padl(alltrim(str(t1.nextinvoicenumber)),9,"0")
            t1.close()
            end
            isopen:
            trys=trys + 1
            if trys
            Cole Custom Programming - Terrell, Texas
            972 524 8714
            [email protected]

            ____________________
            "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

            Comment


              #7
              RE: Auto Increment Character Field

              Possibly you are unaware of the INCREMENT_VALUE() function?

              INCREMENT_VALUE() increments the value referenced by
              Variable by one.

              The INCREMENT_VALUE() function operates on date (D),
              character (C), number (N), and Blob (B) variables.
              The function returns the value "1" (C), 1 (B), or 1 (N)
              when Variable equals "". If the variable is type date and
              the variable is unitialized, the return value is
              {31/12/-471}.

              The above should save a bunch of code.
              regards,
              Melvin

              Comment


                #8
                Re: Auto Increment Character Field

                Though this is not a reply perhaps you can help me as I have not learned how to post questions on this board yet. My question is I have 12 thousand records to import into alpha 5 ver 8. How do I automatically have alpha put in a unique number in each field. I have figured out how to auto increment but I don't want to put in a unique field in each record. I would appreciate any help.

                George Schaefer

                Comment


                  #9
                  Re: Auto Increment Character Field

                  Originally posted by georgegeneschaefer View Post
                  Though this is not a reply perhaps you can help me as I have not learned how to post questions on this board yet. My question is I have 12 thousand records to import into alpha 5 ver 8. How do I automatically have alpha put in a unique number in each field. I have figured out how to auto increment but I don't want to put in a unique field in each record. I would appreciate any help.
                  George,
                  To post a question, go to the forum that you desire (v8) and press the "New Thread" button at the top of the forum list.

                  As far as your question, I recommend you ask it in a separate thread as it is bad form and can get confusing mixing up two folks questions in one thread. And when you post your question, please clarify what I highlighted in red. I am not understanding what you are trying to say... ie ? in each field? ? don't want a unique fields in each record?? Are you trying to say you do (or do not) want "a field with a value that is unique to that record"?
                  Mike W
                  __________________________
                  "I rebel in at least small things to express to the world that I have not completely surrendered"

                  Comment


                    #10
                    Re: Auto Increment Character Field

                    I apologise once more but I guess I don't know how to start a new thread here.Perhaps you will still help me. (groan - its terrible to be ignorant) I have an old db which I have imported into alpha ver 8. have 13000+ records with no unique field in them. Using alpha I see the need to have a unique field in each record but although I have figured out how to add that field, I have not figured out how to automatically fill that field in the imprted records. I can do new records but not old records. There must be a way. help if you know of a way.
                    George Schaefer

                    Comment


                      #11
                      Re: Auto Increment Character Field

                      Originally posted by georgegeneschaefer View Post
                      I apologise once more but I guess I don't know how to start a new thread here.Perhaps you will still help me. (groan - its terrible to be ignorant) I have an old db which I have imported into alpha ver 8. have 13000+ records with no unique field in them. Using alpha I see the need to have a unique field in each record but although I have figured out how to add that field, I have not figured out how to automatically fill that field in the imprted records. I can do new records but not old records. There must be a way. help if you know of a way.
                      George Schaefer
                      Turn off/remove the auto increment rule. Create an update operation (control panel, operations tab) for the unique value field.

                      Suppose the field to hold the unique value is named "rep". Suppose you want the field values to start at "0000001". The update operation would look like my attached screenshot.

                      You can then put the auto-increment rule back in place to handle new records.
                      There can be only one.

                      Comment


                        #12
                        Re: Auto Increment Character Field

                        would it not be simpler to just set the field to recno() or str(recno(),whatever) if a character field?

                        Dave
                        Dave Mason
                        [email protected]
                        Skype is dave.mason46

                        Comment


                          #13
                          Re: Auto Increment Character Field

                          Originally posted by DaveM View Post
                          would it not be simpler to just set the field to recno() or str(recno(),whatever) if a character field?

                          Dave
                          Dave

                          When doing the load (works if it gives an appropriate value) or instead of an auto-increment? (bad idea - deleted records could result in duplicated values)
                          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.
                          "Make it as simple as possible, but not simpler."
                          Albert Einstein

                          http://www.iadn.com/images/media/iadn_member.png

                          Comment


                            #14
                            Re: Auto Increment Character Field

                            Al,

                            Maybe I was lucky when I did this, but it worked great on an existing table. In fact I managed to do A set with 0.00 errors. The method Stan(see his pic) used seemed to me to be after the records were in. One would hope to have packed the table and done the essentials prior to any such update operation on any field in any table/set. Do you not think? Even if you added records later via import/or. they would still follow the then autoincremented field rules.


                            deleted records could result in duplicated values
                            Not hardly in my experience, a deleted record could cause a skip in increments with active records. I have had that before.

                            Dave
                            Dave Mason
                            [email protected]
                            Skype is dave.mason46

                            Comment


                              #15
                              Re: Auto Increment Character Field

                              Al,

                              I sounded harsh there. Did NOT mean to.

                              Dave
                              Dave Mason
                              [email protected]
                              Skype is dave.mason46

                              Comment

                              Working...
                              X