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



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

update a child table

  • Filter
  • Time
  • Show
Clear All
new posts

  • update a child table

    I have a customer table... (doesn't almost everyone?)
    and a child table.. customer items...
    c_customers.dbf with serial id, cus_id
    c_customer_items.dbf with serial id, unit_table_I_D
    and a linking field unit_cus_I_D

    due to the complexity of the sets, I need to seed the customer items table with a dummy record for all of the customer records who do not (yet) have an item record.
    (Lack of item record is due to the lack of info about some of the customers. This will be resolved over time as the customers repeat..)

    In order to complete appointments and schedules tables, each customer has to have at least one record which contains 'adders' to be posted to appts and/or scheds.....

    Basically, I understand how to open the customer table, 'grab' the id # and then make a new record in the cus item table...
    What I don't know how to do is the check for an existing record under that customer....

    If someone could give me a place to research or a basic outline of what must be done to accomplish this, I would appreciate it immensely.


  • #2
    RE: update a child table


    A quick way to do this would be to use Key_Exist() to determine if an index key is present in the child table's serial id index.

    A slow way would be to open another instance of the child table, set the index to serial id, and do a fetch_find(). If successful you know you have a record, if fails you know you don't.

    -- tom


    • #3
      RE: update a child table

      Ok thanx
      I have to 'run thru' the customer table and check each cus id for a key in the customer item table....

      thought I'd use something like:

      while .not. eof
      if .not. item_cus_id = cus_id
      fill in the dummy record
      next record in cus table
      end while

      gonna take a bit of 'mental exercise' and research, but I think I can come up with the code to make it work.....

      thanx again


      • #4
        RE: update a child table

        I misread what you said...
        I can't use the serial id # in the cus_item table, I have to use the linking field, which matches the cus_id #....
        Got the basic idea, tho, so I'll work on it over the weekend...

        See ya later


        • #5
          RE: update a child table

          Probably can use exist() rather than key_exist()....
          that way I can check the linking field in the child table by field name....
          with both tables open, I can use the cus_id to check against the existence of unit_cus_I_D = to cus_id in the child table....
          thanx for the 'point in the right direction'!!


          • #6
            RE: update a child table

            Here's the first try at the table update.
            I don't want to try it until I get some idea of how 'good' or 'bug free' it is....
            It compiled error free but.....???

            Any comments will be appreciated.

            'dim all the variables
            'dim shared test_id as C

            'first open table c_customers.dbf
            'next open table c_customer_items.dbf
            ' table.c_customers_fetch_first()
            while .not. tbl1.fetch_eof()
            ' test_id = cus_id
            if exist (tbl1.cus_ID,"c_customer_items.dbf","unit_cus_I_D")
            end if
            end while
            'update indexes
            dim tbl as P
            dim idx as P

            tbl = tbl2
            idx = tbl2.index_open(A_DB_CURRENT_PATH + "customer_temp.cdx")

            'Index update requires exclusive access to the table.
            'If you do not have exclusive access, an error is generated.

            on error goto error_handler

            ui_msg_box("Error","Index was not updated. Cannot get exclusive access to table", UI_STOP_SYMBOL)
            resume next


            • #7
              RE: update a child table


              the general idea looks about right.

              1) don't you want resume 0 instead of resume next?

              2) The sequence used to open the two tables looks wrong.

              tbl1="c_customers" 'assigns char string to var
              tbl2="c_customer_items" 'ditto
     'syntax wrong ????
     'syntax wrong ????

              Check the docs for correct syntax on


              3) Your script needs to clean up after itself. In its present for it would leave the two tables open (once you fix the statements. Remember to close them both before your script ends.

              4) Use debug(1) to step through the script

              -- t


              • #8
                RE: update a child table

                OK, I now see that!
                next crazy idea....
                if I open a form that is based on a set containing both of these tables, then they are both automatically opened...?
                If I resync the form after each 'fetch' (action or not) would I be able to see the records being displayed on the form.???? Albeit maybe too fast to read...????
                This, to me, would be good cuz I could see that the script is working, and then later, just open the form 'hidden'. This would also assure that all the field rules are in use during the formation of new records....


                • #9
                  RE: update a child table

                  Well the debugger has driven me crazy long enough...
                  No matter what I do, I keep getting 'variable mis-match' on the first line of the code... and it doesn't seem to matter if I change the code.... Even a 'dim' statement gives me the error....
                  Goin' nuts,
                  looking into it


                  • #10
                    RE: update a child table

                    finally got it to work and it did fine -- in a way....
                    for every customer that DID NOT HAVE a customer item entry, I was able to insert a new record in the customer item table with 5 fields filled in.... these 5 fields did not have any data in them at the time of the 'update'...
                    However, I tried to change the data in 3 other fields and got the 'subelement cannot be assigned to' error... The fields are numeric.

                    I re-wrote the script using tbl2.change_begin(), etc and re-ran the script.... got the same error....

                    Earlier, I had run an update operation to 'insert a calculation' into these same three fields. Is there some kind of conflict here...

                    the update script is below....

                    'Date Created: 08-Oct-2004 09:16:53 PM
                    'Last Updated: 09-Oct-2004 05:30:05 PM
                    'Created By : Administrator
                    'Updated By : Administrator

                    dim tbl2 as p


                    while .not. tbl2.fetch_eof()
                    end while


                    • #11
                      RE: update a child table

                      The "tbl.commit()" is not needed and is probably the thing generating the error.

                      Read the text explaining how change_begin() and change_end() work. You'll find that commit() is not necessary. In fact, it's a method of form objects, not table objects.

                      -- t