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

assign incrementing values to child records, start at zero with each parent key

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

    assign incrementing values to child records, start at zero with each parent key

    Hello

    does anyone know how to run and update script that will assign incrementing numeric values to child records, based on their association with the parent?

    eg cars and color choices, update below color_choice_number

    if a car has 8 color choices, the color_choice_number fields of the CHILD records would read 0,1,2,3, -> 7 (being the eighth choice)

    parent = car_id

    child = car_id, color_choice, color_choice_number

    thanks !!!
    Logical Design
    Keven Thibeault
    Boston, Massachusetts
    Dwell in possibility

    #2
    Re: assign incrementing values to child records, start at zero with each parent key

    Along these lines?

    Numbering browse lines.
    There can be only one.

    Comment


      #3
      Re: assign incrementing values to child records, start at zero with each parent key

      Originally posted by Stan Mathews View Post
      Along these lines?

      Numbering browse lines.
      this approach does work - but SLOWLLLLYY ... It took 60 seconds to update 3 rows, on a speedy new machine. the child records are about 5000 in total, but each child grouping is about 2-3, up to about 30 child records. any hints to speed this bad boy up??!
      Logical Design
      Keven Thibeault
      Boston, Massachusetts
      Dwell in possibility

      Comment


        #4
        Re: assign incrementing values to child records, start at zero with each parent key

        Keven, is this something that would be done only once? If it's apt to be run periodically, is it ok if the id number for a given color changes or do you need to lock the number down? I'm thinking of a custom script that sorts the child table by car_id, and then by color_choice. The script would then fetch through all the records using a loop to begin the number sequence again when the car_id field value changes. This could be used to populate the color_number fields. But you wouldn't want to run it twice if the color choices for a car might have changed. Still, if a script like this would be useful let me know.

        Comment


          #5
          Re: assign incrementing values to child records, start at zero with each parent key

          K,
          I don't know about an update. If you are just looking for the next number in sequence for that particular car_id when entering records, then try this on a New Record button, or a form or field event of your choice.

          Code:
          [COLOR="Blue"]'variable for the next number. if only 0-8, this could be Character[/COLOR]
             dim vnxtno as N     
          [COLOR="blue"]Variable for car_id.  This should be a character field since not likely 
          ' involved with math functions[/COLOR]
             dim vcarid as C 
          [COLOR="Blue"]' acquires parent car_id value[/COLOR]
             vcarid = parentform:car_id.value  
          
          [COLOR="blue"]'establishes the filter for the child tables[/COLOR]
             vfilter = "car_id = "+quote(vcarid)	
          
          [COLOR="blue"]' probes the child table to check if first record, if yes, then next =0, 
          ' if not, increment from the max[/COLOR]
             if a5_get_records_in_query("childtablename",vfilter) = 0 then
                then vnxtno = 0
             else
                vnxtno = increment_value(tablemax("childtablename",vfilter,"color_choice_number"))
             end if
          [COLOR="blue"]' use the value in vnxtno for the color number for the next record[/COLOR]
          parentform:color_choice_number.value = vnxtno
          LATER:
          Actually, all you'd need would be this:
          Code:
          dim vnxtno as N
          	
          vnxtno = a5_get_records_in_query("childtablename","car_id = "+quote(vcarid))
          parentform:color_choice_number.value = vnxtno
          Last edited by Mike Wilson; 10-06-2007, 10:00 AM.
          Mike W
          __________________________
          "I rebel in at least small things to express to the world that I have not completely surrendered"

          Comment


            #6
            Re: assign incrementing values to child records, start at zero with each parent key

            Good morning, Mike.

            We need Keven to clarify his situation. Is he talking about assigning the next color_choice_number to each child table record as it gets entered, or is he trying to assign grouped sequential numbers to all the child table records in the table ?

            Comment


              #7
              Re: assign incrementing values to child records, start at zero with each parent key

              Good morning, Tom,
              Yes, I see, you are absolutely right. He does use the word update, twice, doesn't he. The water is boiling now, so the first cup of coffee should be taking hold soon...
              Mike W
              __________________________
              "I rebel in at least small things to express to the world that I have not completely surrendered"

              Comment


                #8
                Re: assign incrementing values to child records, start at zero with each parent key

                Yes... I actually need to have the row count, run as a global update to a set, or to two tables.

                I dont need it just to display, if there are 20 child records, I need to sequence the values 1,2,3->20 for each of the child records

                As i mentioned, the script works, while viewing a set form, but is so incrediblly slow, it is faster to export the data to excel, and MANUALLY cut an past down the file.

                so obviously any help would be greatly appreciated
                Logical Design
                Keven Thibeault
                Boston, Massachusetts
                Dwell in possibility

                Comment


                  #9
                  Re: assign incrementing values to child records, start at zero with each parent key

                  Is he talking about assigning the next color_choice_number to each child table record as it gets entered, or is he trying to assign grouped sequential numbers to all the child table records in the table ?
                  K, I can't tell which question you're answering, and don't understand your answer. Would like to help, but need you to try harder to describe exactly what you need, and the context in which the process would run.

                  -- tom

                  Comment


                    #10
                    Re: assign incrementing values to child records, start at zero with each parent key

                    Assign the grouped sequential numbers globally in a single pass via an update script.

                    NOT during data entry mode

                    thanks again!
                    Logical Design
                    Keven Thibeault
                    Boston, Massachusetts
                    Dwell in possibility

                    Comment


                      #11
                      Re: assign incrementing values to child records, start at zero with each parent key

                      Kevin
                      It woud only involve a simple default field rule to assign the sequence number
                      during data entry which would negate the slowness of your update program.
                      Could you explain why this would be unsatisfactory.The end result would be the same wouldn't it?
                      John

                      Comment


                        #12
                        Re: assign incrementing values to child records, start at zero with each parent key

                        K, thanks. Unless you care to post sample tables for us to use I plan to use the invoice header and item tables in AlphaSports. Will change structure of the items table to include a sequence number field, and then will write a script that steps through the items table numbering items for each header record consecutively. This should be easily adaptable to your situation I should think. -- tom

                        Comment


                          #13
                          Re: assign incrementing values to child records, start at zero with each parent key

                          K,

                          Here's the example for you. Unzip and extract to an empty folder.

                          I've defined an update operation to zero out all the seq field values.

                          Then I've written a script to renumber them sequentially. You'll find the script on the code page of the control panel.

                          -- tom

                          Comment


                            #14
                            Re: assign incrementing values to child records, start at zero with each parent key

                            THIS EXAMPLE WORKS LIKE A CHARM! Thanks to Tom Cone Jr - and his clever coding, this will make the application run like a champ

                            THANK YOU Tom !!
                            Logical Design
                            Keven Thibeault
                            Boston, Massachusetts
                            Dwell in possibility

                            Comment


                              #15
                              Re: assign incrementing values to child records, start at zero with each parent key

                              Interesting!!
                              Why does it have to be done 'after the fact'?? Why not do it as the record is made??
                              Use the parent record incrementing id and add a sequence number to it. Record id's do not have to be automatic, incremented values. Record numbers can be used for that kind of query. Doing that would make default browses easier to read and dissect.

                              Deserves a good look!!
                              D

                              Comment

                              Working...
                              X