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

updating primary table from child

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

    updating primary table from child

    I have a primary table "demoggraphics" which is linked to a child table "followup". I would like to update a field "period" in the primary table based on a field "wks" in the child table. However, the update is a result of categorizing the data in the child table as follows:


    SELECT
    case wks > 1 .and. wks < 3
    period = 2
    case wks > 4 .and. wks < 7
    period = 6
    ...... (several more classifications)

    End Select

    I am trying to set this up as a record event field rule, so that after the record is saved, the event fires which performs this calculation and posts the result to the primary table. The update is performed on a form which is based on a set with these two tables linked.

    What is the syntax for addressing the fields "wks" from the child table and "period" from the primary table when the event fires while my form is open to the child table? I know I have to create table pointers.

    Thank you!
    dave
    David A. Volgas, MD

    #2
    Re: updating primary table from child

    David:
    Several ways you could do this but first, you could fine-tune this script a bit as follows:
    SELECT
    case wks <4
    period = 2
    case wks < 7
    period = 6
    .etc.

    End Select

    You probably will get a dozen different suggestions varying from table.open() to table.current() to posting to who knows what. But the simplest of them all is to put a script on the OnSave event of the form that says:

    wks.value=period

    The above makess the assumption that the object name on the form is the same as the field's name, i.e. "wks".

    I can't tell what period is? a variable? a field name? but that is not important, only perhaps in terms of getting the proper reference.

    I said earlier "the simples" and I lied.
    The simples would be:
    SELECT
    case wks <4
    wks.value= 2
    case wks < 7
    wks.value = 6
    .etc.

    End Select
    Assuming you don't care to set the value of whatever "period" is.
    Last edited by G Gabriel; 01-08-2009, 04:59 PM.

    Comment


      #3
      Re: updating primary table from child

      Is this a one to many set or a one to one set?
      There can be only one.

      Comment


        #4
        Re: updating primary table from child

        Thanks, Stan, this is a one-to-many set. The update needs to happen after I update the child table.

        The issue is that I don't knwo the syntax for addressing both a child table field and a parent table field in the same expression. Do I use a pointer to each table (but how do I select the correct record within that table) or do I assume that the record cursor remains at the current position in the child and parent table. Or is it easier to simply address the form variable?

        Dave
        David A. Volgas, MD

        Comment


          #5
          Re: updating primary table from child

          I'm still struggling with what you want to do when.

          The update is performed on a form which is based on a set with these two tables linked.
          So you have a parent record visible and edit/enter a child record, and want to update a field in the parent based on what happens in the child record? Are you editing the child record in a browse? (seems likely) You want the parent record updated according to the last record in the browse (don't want any changes to earlier records used to update)?

          Do I use a pointer to each table
          Yes. The parent pointer is obtained with table.current(1), the child with table.current(2)


          (but how do I select the correct record within that table)
          Thus obtained the current selected row in the browse would be the record used.
          There can be only one.

          Comment


            #6
            Re: updating primary table from child

            precisely! I am using a browse to edit the child record and wish to use a value from the child table to calculate a value to place in the master table.
            David A. Volgas, MD

            Comment


              #7
              Re: updating primary table from child

              use a value from the child table
              Which record in the child table?
              There can be only one.

              Comment


                #8
                Re: updating primary table from child

                Here's the setup

                Parent table
                MRN as C
                period as N
                Child table
                MRN as C
                daysfu as N

                The two tables are linked by MRN

                The browse contains the field daysfu

                the routine should be:

                wks = daysfu / 7

                select
                David A. Volgas, MD

                Comment


                  #9
                  Re: updating primary table from child

                  Here's the setup

                  Parent table
                  MRN as C
                  period as N
                  Child table
                  MRN as C
                  daysfu as N

                  The two tables are linked by MRN

                  The browse contains the field daysfu, the main form has the parent field "period" displayed on another tab.

                  the routine should be:

                  wks = daysfu / 7

                  Select
                  case wks < 4
                  period = 2
                  case wks < 7
                  period = 6
                  case wks < 14
                  period = 12
                  .....
                  End Select



                  Dave
                  Last edited by davidv43; 01-09-2009, 02:11 PM. Reason: sorry - hit the wrong button..
                  David A. Volgas, MD

                  Comment


                    #10
                    Re: updating primary table from child

                    The browse contains the field daysfu,
                    For each record in the browse.

                    first record in browse - I know how to update parent table
                    add a second record in browse - probably want to update parent table with new value
                    go back and edit first record - ??? what should happen
                    add a third record in browse - probably want to update parent table with new value
                    delete third record in browse - ??? what should happen
                    There can be only one.

                    Comment


                      #11
                      Re: updating primary table from child

                      David:
                      Did you read what I wrote earlier?
                      I believe you did and probably I was not clear enough or got the names of the fields backwards. I am struggling with my computer, so I will be brief but hopefuly clear enough.

                      You could put a simple script on the onsave event of the form that says:
                      select
                      case browse1:wks<3 'this assumes the column title is "wks". Change if different.
                      period.value=2
                      etc
                      end select
                      topparent.resynch()

                      Comment


                        #12
                        Re: updating primary table from child

                        Thank you Gabriel. It looks like you are using the field names to change values.

                        Do you have to use .value to change data in form fields?

                        Dave
                        David A. Volgas, MD

                        Comment


                          #13
                          Re: updating primary table from child

                          Stan,

                          I used table pointers as follows:


                          dim demotbl as table '(primary table)
                          dim fu_tbl as table '(child table)
                          dim t as n 'variable

                          demotbl = table.current(1)
                          fu_tbl = table.current(2)

                          t = fu_tbl.dof - demotbl.doi 'use the dof field from the child table and the

                          if t > demotbl.daysfu then
                          demotbl.daysfu = t
                          end if
                          David A. Volgas, MD

                          Comment


                            #14
                            Re: updating primary table from child

                            Stan,

                            I used table pointers as follows:


                            dim demotbl as table '(primary table)
                            dim fu_tbl as table '(child table)
                            dim t as n 'variable

                            demotbl = table.current(1)
                            fu_tbl = table.current(2)

                            t = fu_tbl.dof - demotbl.doi 'use the dof field from the child table and the
                            doi field from the primary table

                            if t > demotbl.daysfu then ' if the result is less than what is stored in the primary record, do not update

                            demotbl.daysfu = t
                            end if
                            David A. Volgas, MD

                            Comment


                              #15
                              Re: updating primary table from child

                              No..
                              The way I described it above is one way but is not in my openion the best way and is not how I would do it. But I mentioned it because some people got
                              their heads stuck on this ".value" thing. Somehow somewhere either in the help file or someone from alpha got everyone on board with this.

                              My preferred method is to do it like this:

                              select
                              case child_table->child_field<3
                              parent_table->parent_field=2
                              ....
                              end select
                              topparent.resynch()

                              P.S. I have reached max level of aggravtion! I can't type anymore, the cursor keeps jumping allover the place. I am pretty darn sure it is not my compute. It's happening with several ones. But the above should be self-explanatory.

                              Comment

                              Working...
                              X