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

Autoincrement in a set

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

    Autoincrement in a set

    I need to assign numbers to child records in an embedded browse, (lineitems).
    In Alpha 4 this was simply done using a default expression of "system->reg_recnum".
    Apparently autoincrement in A5 does not work with child records in a set. I have looked at the various posts on this site and Dr. Waynes articles. It seems that autoincrement has been made much harder in A5. Is there a simpler way than to put in a bunch of code on the record events? Does anyone know if this is addressed in V5? I can't see that there is any change here. Is there something I am not aware of in A5 that is equivalent to system-> reg_recnum?

    Thanks in advance
    Russ

    #2
    RE: Autoincrement in a set

    Russ,

    If you want to number line items in an embedded browse Dr. Wayne's web site has an article that shows how to do it. If you just want a field in the child table (not the linking field to the parent) to autoincrement I am pretty sure you can use a field rule. If you autoincrement a field in the parent table and set it as the link to the child any child records you create in the set will carry the value in the parent, obviously the same value for all children of the same parent.

    If it is none of the above, I don't see what you are trying to do.

    Bill
    Bill Hanigsberg

    Comment


      #3
      RE: Autoincrement in a set

      Hi Russ:

      It seems that I've read a bunch of posts concerning this very thing. So, for my own application, I thought I would try it and see what happened. I have a checkbook set - a single-record-header with a one-to-many child. It has functioned flawlessly for about 80 entries now and moving nicely. I set it up as "Numeric" - 8 characters/integers long and just checked 'auto increment' in the field rules for the set.

      The only trouble I had was this. Following the old A4 patterns, I put this as the last field on the browse in the form. When it was there, it would auto-increment fine but then save and start a new record with no interaction from me. Didn't like that, so I just moved it over to the next-to-last field there and voila! - it works.

      I notice that if you delete (and pack) a record, that number is missing from the sequence and thought that might be something usable in an application-for-sale. - Would tip off a deleted record that might be recovered before packing, if need be. I've also copied this same setup in an application that I'm building for sale, and don't currently have any reservations about it. Funny thing. I IS the last field on that new form's browse and doesn't perform like that position did on the first one. Go figure?

      Let me know of your troubles, if any.

      Newbie Ken

      Comment


        #4
        RE: Autoincrement in a set

        Russ, are you trying to store the child table record number in each child record?


        I dug out my Alpha Four book and could not find the "system->reg_recnum" you mention. There is such a thing as "system->rec_number" which contains the record number of the current record. Is this what you meant to refer to?


        So far as I can tell this has nothing to do with auto-incrementing values in a table. However, it could be used to store the current record number in each child table record as that record was being added to the table.


        Alpha Five has the equivalent functions to return the current record number so if that's what you are trying to do we can suggest methods for you. If I'm on the right track you may want to re-think this anyway, depending on how the record number identifier is used in the child table. You should not expect it to produce unique results in each record. If a record is deleted and the file is packed record numbers at the end of the table will be used over again. Duplicate values will exist in the table in this case.

        Comment


          #5
          RE: Autoincrement in a set

          Thanks to you all for the responses. I will try to respond to all.
          Bill,
          Looked at Dr Wayne's article. I am sure this will work, but it seems that I should be able to do something so simple in field rules. It appears (let me know if I am wrong) that autoincrement will not work for child records- at least it seems to not work for me. If this this could be built into A5v5 as a field rule option.
          Ken
          I've got to try this again, I tried it a few times and it didn't work for me on a one to many where the field to be incremented was not a linking field.
          Tom
          I checked and yes system->reg_recnum does exist and works to number records in a one to many child. I det it as the default expression. As for the other point of the records numbers changing this is not an issue as it is the default and is read only on the embedded browse so the user can't change it and it will only fill in once as the default. On change it stays the same.

          I'll get back on this, Ken if this works for you I don't see why it doesn't for me. (Maybe you shouldn't call yourself the newbie andymore, I think others like me can take that title now)

          Russ

          Comment


            #6
            RE: Autoincrement in a set

            Oops, the last post was supposed to go here.
            I tried the autoincrement on a child of a 1 to many set and it doesn't work. Ken if you got it to work I would like to know what you did.

            Russ

            Comment


              #7
              RE: Autoincrement in a set

              Russ, if you would be good enough to point out system->reg_recnum in the Alpha Four Reference Manual, I'd like to read up on it. Also, it's possible my last post wasn't clear. If you use recordnumbers as identifiers in your table you're leaving the door open for duplicates. Consider a simple table with 10 records. When the 11th record is added the identifier field is assigned an '11' right? Assume for the moment that the user deletes record number 3, and then packs the file. It now contains 10 records again. So when the next record is added the identifier field is assigned an '11', and you wind up with two records back to back with duplicate values.

              Comment


                #8
                RE: Autoincrement in a set

                If I understand what you want, I have your solution. I have a set for Repair Orders. Each RO has Repairs that need to be made. So, establish a field called Problem_ID. Put this in the field rule, data entry default value:

                IF(EXIST(RO_ID, "REPAIR", "RO_ID"), RIGHT("00" + LTRIM(STR(VAL(LOOKUPC("L", RO_ID, "PROBLEM_ID", "REPAIR", "RO_ID"))+1)),2), "01")

                There's also a field called RO_ID which ties the set together, and a corresponding in index in Repairs.dbf. So, the expression says:

                If the RO_ID already exists in the Repairs.dbf RO_ID index, then get the last instance of that index key and increment it. Otherwise, the default value is "01."

                Make sense? Solve your problem? Hope so.

                - Steve
                -Steve
                sigpic

                Comment


                  #9
                  RE: Autoincrement in a set

                  Tom:
                  The system-reg that you refer to is a system region number.
                  In alpha4 you can have regions (embedded browses)
                  On page 2-6 of the yellow and white Alpha4 manual it shows a picture of a region and on page 13-10 it gives the definations of the system fields.
                  One of the system fields is called reg_recnum. It is a sequence number for each child record in a scrollable region. It is useful for automatically numbering line items.
                  It changes when the records are deleted and packed.I use it for data entry, so the users can tell how many lines they have entered.It is an optional field. It always calculates but you dont have to show it on the screen if you don't want to.
                  Charlie Crimmel

                  Comment


                    #10
                    RE: Autoincrement in a set

                    I've attached a sample database which illustrates that the autoincrement field rule does work for non-linking fields in a child table, when data entry is occuring inside the set.


                    The set is called Families.
                    The parent table is called Parents.
                    The child table is called Children.


                    The linking field is FamilyNumber. It's set to autoincrement in the Parents table.


                    The nonlinking field which is autoincremented in Children table is called ChildNumber. As records get added to the Children table through the default form for the Families set, this field is incremented automatically.

                    Comment


                      #11
                      RE: Autoincrement in a set

                      Oops! here's the attachment.

                      Comment


                        #12
                        RE: Autoincrement in a set

                        Charlie, thanks. That explains a lot. I could not find it using the index.

                        Comment


                          #13
                          RE: Autoincrement in a set

                          Thanks for all the help.
                          This is really weird. I tried tom's set and it works fine autoincrementing the child record, yet in mine it doesn't do it. It seems to keep the last highest child number and use that for the next child. In other words when I create a new child record number 3 then go to a different parent with no child records the first child record becomes 4 and so on. It is not resetting the child record number and hence treating the child records as if they were parent records.
                          I wonder if this has something to do with the fact that these records were created in A4, not in A5? I've got to play with this some more. Any ideas will be appreciated. This should be easy arrrrrrrrrgh.

                          Russ

                          Comment


                            #14
                            RE: Autoincrement in a set

                            Tom
                            This gets weirder. I looked at your set again. I see that you have 2 parents with prooperly numbered children records. I added a new one to an existing parent and it numbered correctly. Then I added a new parent record and a new child record. The first child is numbered 11 !!!. This is incrementing on the last highest record. I wonder if I have some sort of system problem if your machine doesn't do this.

                            Russ

                            Comment


                              #15
                              RE: Autoincrement in a set

                              Are you using the field rule that Steve W. posted?? That should do the job. The only problem you should get is if you go over 99 child records.

                              Comment

                              Working...
                              X