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

Passing primary key in set

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

    Passing primary key in set

    I am quite new to Apha Five (less than two weeks). I created a one-to-many set and I don't want to use the browse to enter "detail" records. I want to pass the primary key to the default form for the secondary table for an "Enter Record" operation. I would think that this is a common situation but could not find a method to accomplish this. Is it necessary to use Xbasic and somehow store the primary key in a shared variable and make the primary key a calcualted field in the "detail" record that accesses this variable?

    #2
    Re: Passing primary key in set

    1) the xbasic is very easy. See "pass values between forms" in the Code Archive forum for examples developed before action scripting was enhanced

    2) action scripting can now write this code for you. the sequence would be:
    - open the called detail form but keep it hidden from the user
    - begin a new record in the hidden form
    - assign the key field value to the foreign key field in the called form
    - set the foreign key field to be read only in the called form
    - show the called form to the user

    Comment


      #3
      Re: Passing primary key in set

      Thanks. I used the global variable option but I had to use OnEnter. OnInit flashed the value in the field for a second, then went blank.

      Comment


        #4
        Re: Passing primary key in set

        From the "New in V8" website
        Code:
        A5_open_EmbeddedBrowse_CompanionForm() Function - This function is designed to be  used in a button or an event on a form that is based on a set with one-to-many child tables. It opens a pop-up form to edit the current record in an embedded browse, or to add a new record to the table whose records are shown in an embedded browse. While it has always been possible to write the Xbasic code to do this, this function simplifies the process by automatically performing the resynchronization necessary to cause the embedded browse to correctly display the edits that were made in the pop-up form. A new action in Action Scripting has been added to automate calling this function.
        
        The syntax for the function is:
        
        a5_open_EmbeddedBrowse_CompanionForm()  as p (mode as c, targetFormName as c, formPointer as p, browseName as c, targetTablePrimaryKey = "Recno()", linkDef = "", otherOptions = null_value())
         
        
         Where:
        Mode 	
        
        "Edit" or "Add" - indicates if you want to edit the current record in the embedded browse, or add a new record
        targetFormName 	Name of the form to open to edit the records.
        formPointer 	A pointer to the form whose records you want to edit. If this function is called from an event on the form whose records you want to edit, then you can specify 'topparent.this' to get a pointer to the current form.
        browseName 	The object name of the embedded browse whose records you want to edit.
        targetTablePrimaryKey 	If the Mode is set to 'edit', you need to indicate a primary key expression for the target table (the table whose records you will be editing). This allows Alpha Five to find the correct record to show in the pop-up form. The default value for this argument is 'recno()'. If you are editing data in local .dbf tables, then the default value for this argument should be sufficient. However, you could also specify any expression that uniquely identifies a record in the target table. E.g. 'invoice_number'.
        linkDef 	This optional argument defines the link between the target table (the table whose records you will be editing)  and its parent table. The default value for this argument is blank. If it is blank, then Alpha Five will automatically determine the link definition from the definition of the set on which the form is based. However, if the set definition links the target table and its parent table on an expression, rather than on matching field names, you will need to specify a link definition. The link definition tells Alpha Five what values to put into the linking fields in the target table when a new record is created. Without this information, the new record would not be properly linked to its parent record. The format for the linkDef parameter is a CR-LF delimited list of this form: targetTableFieldName = parentTableFieldName
        otherOptions 	A optional dot variable that specifies additional optional properties. These are:
        
        otherOptions.X_position - x co-ordinate of the pop-up form. Can be 'left', 'center', 'right' or an absolute position in pixels.
        
        otherOptions.Y_position - y co-ordinate of the pop-up form. Can be 'top', 'center', 'bottom' or an absolute position in pixels.
        
        otherOptions.RestrictNavigation - (defaults to .t.) - Indicates if the user can navigate to other records when the pop
        
        Example:
        
        a5_open_embeddedBrowse_companionForm("edit","editLineItems",topparent.this,"browse1")
        
         
        
        This will open a form called 'editLineItems' to edit the current record shown in the embedded browse called 'browse1'. The 3rd argument, 'topparent.this' is just a pointer to the current form.
        Andrew

        Comment


          #5
          Re: Passing primary key in set

          Interesting. Will have to check it out... may be time to update my thinking.

          Comment


            #6
            Re: Passing primary key in set

            I have two other field values from the embedded browse that I need put into the pop up form. (company_id, & contact) These fields are in addition the primary key. Can someone tell me whether I can take care of this with field rules (so far, no luck) or do I need to convert the action scripting to xbasic and try passing the values that way (no experience with xbasic, other than copying action scripting :o. I have attached the database. The parent form is contact_form_01 with the embedded browse in "Notes" tabbed form. Note that the three last entries in the notes table do not have values in "company_ID" nor "contact" fields. I added both fields to the browse and the pop up form, hoping that would make a difference...it didn't.
            Also, Any advice on getting up to speed with programming with Alpha Five. Everytime I've had a question, I get great help, but I don't want to overuse the support and would love the feeling of actually knowing what I'm doing.
            Thanks,
            John

            Comment


              #7
              Re: Passing primary key in set

              As mentioned previously in this thread, there are examples illustrating techniques to pass values between forms available in the code archive forum. May be time to check them out?

              Comment


                #8
                Re: Passing primary key in set

                Thanks Tom. I actually was able to pass those two values along, by assigning the field values in the browse to variables and then passing those on to the form, which is why I had to include those fields on the form (action scripting required the fields to be on the form before I could pass the value) This was fine until I went with the "Open companion form for an Embedded browse". This only passes the primary key (notes_id")
                You are right though. I was just being lazy. I apologize.

                Comment


                  #9
                  Re: Passing primary key in set

                  The code archive examples I referenced also illustrate how to assign field values to objects in other open forms, without declaring variables in both calling and called forms. It occurs to me that your script which opens the companion form could also assign field values in the called form using the same ideas.

                  If you want to pass variables, just define and save the companion form, after embedding global variables in the companion form layout. Then populate the globals in the calling form before the custom companion form is opened.

                  Comment


                    #10
                    Re: Passing primary key in set

                    You will have to excuse me. I am so far behind most of you in my understanding of Alpha Five. It will take me a good hour or two to walk thru and "get" your last post. Again, not your fault, I'm just learning. It took me hours and hours to figure how to open, with Action Scripting, a form and then hide it. (I was looking on the list of actions screen.) Just in case someone else comes along and is as slow as I, there is a good video: "Adding Child Records in a One-to_Many set" found in the Alpha Newsletter Archive: http://was.alphasoftware.com/webserv...e/archive2.a5w. Thanks again for the help.

                    Comment


                      #11
                      Re: Passing primary key in set

                      In Tom's list above on how to pass values from parent to child, One of the instructions is: "set the foreign key field to be read only in the called form" Could someone tell me whether this can be done from the script or need it be done by setting the field rules?

                      Comment


                        #12
                        Re: Passing primary key in set

                        "set the foreign key field to be read only in the called form"
                        This needs to be done in the properties of the key field on the form.
                        There can be only one.

                        Comment


                          #13
                          Re: Passing primary key in set

                          Thank you again.

                          Comment

                          Working...
                          X