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

Populating child record with parents ID

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

    Populating child record with parents ID

    I am using a button to open a child form from a parent in Enter mode. I have successfully used Action scripting by using the SET Fields Value command to set the child's foreign key to the proper ID from the parent.

    The problem is that it only works on the first record that is created. If the user creates a 2nd record the linking field is left blank.

    #2
    Re: Populating child record with parents ID

    The problem is that it only works on the first record that is created. If the user creates a 2nd record the linking field is left blank.
    Since creating a child record in this manner is not like creating one in a browse, I would suggest you don't allow multiple entries in the form. Make the user close the form and return to the parent record. Probably could be accomplished by restricting navigation on the entry form.
    There can be only one.

    Comment


      #3
      Re: Populating child record with parents ID

      There was a new function introduced in v8 that is perfect for this situation. It seems to get overlooked. But no wonder as there is no action script equivalent and it has not made it into the regular documentation yet. You can find it in the 'What's new in v8' document. This is a different link to the one in the v9 help.
      A form opened with this function will force each new record to contain the values specified in the link expression/s. If the field/s that is/are specified in the link expression are on the form they will not be editable thereby keeping the link safe.

      If this needs to be part of a longer action script then use the Inline Xbasic action to get it into you script.

      Below is the relevant section from the above link
      Form.ViewLinked() Method - This new method is similar to the .ViewQueried() method in that it opens a form showing selected records. However, with the .ViewLinked() method, you can specify how the target form (i.e. the form that is opened by this method) is linked to a parent table, and Alpha Five will automatically ensure that the correct values are entered into the linking fields when a record is edited or created, ensuring that the records edited/created in the target form remain properly linked to their 'parent' record.

      P formPointer = Form.ViewLinked (C LayoutName , C LinkDefinition [, C filter_expn [, C order_expn [, C style [, C x_position [, C y_position [, OtherOptions ]]]]]])
      OtherOptions.Restrict_Navigation = .f.

      Where:
      formPointer A pointer to the form that is opened.
      LayoutName The name of the form to open. This is called the 'target' form.
      LinkDefinition A CR-LF delimited list of link conditions in the form of: linkTableField = linkValue
      e.g.
      firstname = "john"
      lastname = "smith"

      Filter_expn An optional filter to apply (in addition to the filter implied by the LinkDefinition) when the target form is opened. For example using the sample LinkDefinition shown above, the target form is automatically filtered using
      firstname = "john" .and. lastname = "smith"
      If you only wanted to see records for John Smith where the transaction date was in January, you might specify a filter_expn of:
      month(transactionDate) = 1

      Order_expn An optional order expression.
      Style The style in which the target form should be opened. Options are: null - open as a regular modeless form, 'dialog' - open as a modal form, 'dialog_newrecord' - open as a modal form showing a new record, 'hidden' - hidden until the .show() method is called on the form pointer, 'hidden-dialog' - hidden until the .show() method is executed on form pointer (or some other method that causes the form to become visible, such as .new_record() is called). Default value is null.
      X_Position Left, Center, Right, Fill or an absolute position expressed in pixels. Default value is null, which uses the definition stored in the form layout.
      Y_Position Top, Center, Bottom, Fill, or an absolute position expressed in pixels. Default value is null, which uses the definition stored in the form layout.
      OtherOptions A dot variable. Currently supports a single property. OtherOptions.Restrict_Navigation. Indicates if navigation from record to record is allowed when the target form is opened. Typically, when the user is viewing the last record in a query and he/she navigates to the 'next' record, Alpha Five displays a new record. If you want to prevent the user from navigating to a new record, set this property to .t.

      Example:
      The following command opens the 'InvoiceItems' form and ensures that any records either edited or added are automatically linked to the correct parent record (which has an InvoiceNumber of 'INV1234'). Assume for demonstration purposes that the InvoiceNumber field in the target table (i.e. the table on which the target form is based) is called 'InvNum' (and not 'InvoiceNumber' as it might be called in the parent record).

      dim LinkDef as c
      LinkDef = "InvNum = \"INV1234\""
      dim p as p
      p = Form.ViewLinked("InvoiceItems",LinkDef)

      Tim Kiebert
      Eagle Creek Citrus
      A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

      Comment


        #4
        Re: Populating child record with parents ID

        Originally posted by Stan Mathews View Post
        Since creating a child record in this manner is not like creating one in a browse, I would suggest you don't allow multiple entries in the form. Make the user close the form and return to the parent record. Probably could be accomplished by restricting navigation on the entry form.
        I actually do have the navigation restricted, but it still doesn't prevent a user from using Ctl-E to create a second record.

        Comment


          #5
          Re: Populating child record with parents ID

          Barry, you can "Restrict Enters" in the properties of the form. Examine how many different ways there might be for the user to "Save" the new record. Reduce that to one, by forcing user to click a button. In the button's script modify the properties of the form to "Restrict Enters". when the user saves the record, no further records can be entered.

          Comment


            #6
            Re: Populating child record with parents ID

            Thanks everybody for your help.
            Barry

            Comment


              #7
              Re: Populating child record with parents ID

              Keep meaning to thank Tim for the head's up on form.viewlinked() obviously missed this when V8 came out. It's the best thing since sliced bread as far as calling linked forms is concerned.

              Comment


                #8
                Re: Populating child record with parents ID

                [ edited ]

                Comment


                  #9
                  Re: Populating child record with parents ID

                  Originally posted by Lance Gurd View Post
                  Keep meaning to thank Tim for the head's up on form.viewlinked() obviously missed this when V8 came out. It's the best thing since sliced bread as far as calling linked forms is concerned.
                  Lance, your welcome. And yes it is a very useful function.

                  One thing I have always wondered about is what was the best thing before sliced bread. :)
                  Tim Kiebert
                  Eagle Creek Citrus
                  A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                  Comment


                    #10
                    Re: Populating child record with parents ID

                    One thing I have always wondered about is what was the best thing before sliced bread.
                    Pasteurized milk.
                    There can be only one.

                    Comment


                      #11
                      Re: Populating child record with parents ID

                      Tim,

                      Thank you for the documentation on the form.ViewLinked() method.

                      Can this be used with desktop forms? The reason I ask is that when I looked up the .ViewQueried method, the A5V9 help presented a topic "Define an Alpha Five View Query".

                      The help states that this latter method is limited to web publishing applications only. If viewQueried() is limited to the web, is viewLinked() also restricted.

                      Bob McGaffic
                      Pittsburgh

                      PS If this works as advertised with desktop forms, it has got to be a must have feature for Action Scripting in V10. Another example of Alpha hiding its light under a bushel?

                      Comment


                        #12
                        Re: Populating child record with parents ID

                        Originally posted by Tim Kiebert View Post
                        One thing I have always wondered about is what was the best thing before sliced bread.
                        Originally posted by Stan Mathews View Post
                        Pasteurized milk.
                        Wrong. Pizza!
                        Peter
                        AlphaBase Solutions, LLC

                        [email protected]
                        https://www.alphabasesolutions.com


                        Comment


                          #13
                          Re: Populating child record with parents ID

                          Can this form.ViewLinked() method be used with desktop forms or is it resticted to web applications as the help states for the Alpha Five ViewQuery?

                          Comment


                            #14
                            Re: Populating child record with parents ID

                            Originally posted by rmcgaffic View Post
                            Can this form.ViewLinked() method be used with desktop forms or is it resticted to web applications as the help states for the Alpha Five ViewQuery?
                            Short answer is yes. That is where I am using it. Along with .viewqueried().

                            Not sure how you got to that topic you mentioned called "Define an Alpha Five View Query" but I think that is about running a query against a 'view'.

                            When I type .viewqueried in the help index I get an index entry of .viewqueried(). Clicking on that entry gives me a choice for the browse or form version both are for the desktop enviroment and are restricted to the same.
                            Tim Kiebert
                            Eagle Creek Citrus
                            A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                            Comment


                              #15
                              Re: Populating child record with parents ID

                              Originally posted by Tim Kiebert View Post
                              One thing I have always wondered about is what was the best thing before sliced bread. :)
                              Originally posted by Stan Mathews View Post
                              Pasteurized milk.
                              Originally posted by Peter.Greulich View Post
                              Wrong. Pizza!
                              :D
                              I love both but I think I will have to go with Pizza.

                              I guess that is why I have 10 kilos to loose.
                              Tim Kiebert
                              Eagle Creek Citrus
                              A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                              Comment

                              Working...
                              X