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

How to get pointer to child table from a <form> pointer

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

    How to get pointer to child table from a <form> pointer

    I would like to open a form, that is based on a set. Filter the parent table to a particular record. Filter the child table to a particular record. End result is a form that is open displaying only one Parent record and only one child record associated with the parent record.

    I have been struggling with this all week trying to use form.viewqueried() with no successful. Looking at the documention and what my requirements are I believe that i need to use flattenquery here but always got error messages.

    So I decided to approach from a different angle.

    Open the form with form.load()
    Get a pointer to the parent table with <object>.table_get()
    run a <tbl>.query_create() to filter down to the desired parent record.

    Get a pointer to the child table with ??
    Run a <tbl>.query_create() to filter down to the desired child record.

    How do I get a pointer to the child table? I believe I will have a pointer to the form, from the form pointer can I get a pointer to the child table?

    With the description of what i want in the end, is this a viable method to accomplish it? Or should I revert back to the form.viewqueried() function?
    Andrew

    #2
    Re: How to get pointer to child table from a &lt;form&gt; pointer

    Not sure how it will work in practice but

    ptr = set.current() - pointer to set
    tbl = table.current(1) - pointer to topmost child as seen in set editor
    tbl = table.current(2) - pointer to next highest child as seen in set editor
    etc

    Just noticed this as well.

    You can also get a pointer to an open table using the TABLE.GET() method. For example, if you have opened a set and you want to get a pointer to one of the child tables in the set, (say "Invoice_Items"), you could use this command:

    child = table.get("invoice_items")
    There can be only one.

    Comment


      #3
      Re: How to get pointer to child table from a &lt;form&gt; pointer

      Thanks for the reply Stan.

      set.current() returned the wrong set info. This is because the script that I am writing will be ran from a different form that is based on a different set. Set.current() is returning the set info of the set that is already opened, not the set that the form I am loading is based on. (hope that makes sense, i can re-explain if not).

      I tried to use the table.get() and received this error message
      Code:
      Error # 1002
      No such table
      Script: test
      Line #: 17
      From the <object>.table.get() they have an example of getting a table pointer via a browse object on the form
      Code:
      Example
      
      dim tptr as P
      
      tptr = Customer_Information:browse1.Table_Get()
      
      ? tptr.name_get()
      
      = "CUSTOMER"
      gonna give that a whirl and see what I can't break.
      Andrew

      Comment


        #4
        Re: How to get pointer to child table from a &lt;form&gt; pointer

        gonna give that a whirl and see what I can't break.
        That's what makes life interesting.
        There can be only one.

        Comment


          #5
          Re: How to get pointer to child table from a &lt;form&gt; pointer

          Hi Andy,

          If your child filter is always going to be constant, you can set it in the filter of your set design for the child table. Example: I want to select a person and then only show the work phone number for that person selected. In my set design for the child table link I added a filter for the phone number type field that equals "work".

          Not sure exactly what your filtering expectations are on the parent or child so it is difficult to give much more info at this point.

          You could probably also run a query on your destination set with the filters you need for the parent and child table fields, then load the form based on that filter.
          Cheryl
          #1 Designs By Pagecrazy
          http://pagecrazy.com/

          Comment


            #6
            Re: How to get pointer to child table from a &lt;form&gt; pointer

            Cheryl -

            The filter has to be dynamic to a point. The child table I only want the record where a particular field is blank. So in my first attempts, I placed the filter on the form using the form properties | filter/order tab.

            This worked in that I was able to query the parent table for the needed parent record and then only the child records that needed editing showed. I didnt like this approach because once the field was populated the form filter caused that particular record to dissappear (b/c it no longer matched the filter). Which is why I am having to be more specific and dynamic in my child filter.

            So far in my initial testing the
            Code:
            Example
            dim tptr as P
            tptr = Customer_Information:browse1.Table_Get()
            ? tptr.name_get()
            = "CUSTOMER"
            is working for me. Once I have a pointer to the child table I can place a query on the table using table.query_create() with the query that I need.

            thank you for the help
            -Andy
            Andrew

            Comment


              #7
              Re: How to get pointer to child table from a &lt;form&gt; pointer

              Woot!

              Got the filter to work, thanks for the help :)

              Below is a copy of the code incase someone else is looking for way to do this.

              The only thing I need to work on next is how to refresh the subform on the form that I am opening. The form that I open has both an embedded browse and a subform based on the child record. The browse only shows the child record that matches the filter. The subform needs to be refreshed somehow so that it shows the proper data. Right now I just press "F5" once the form is open to refresh the subform.

              Thank you for the help :)

              -Andy

              Code:
              'Date Created: 04-Dec-2007 09:09:09 AM
              'Last Updated: 07-Dec-2007 02:07:49 PM
              'Created By  : AWS
              'Updated By  : AWS
              OPTION STRICT
              OPTION ENCRYPTED_TOKENS
              ON ERROR GOTO ERR_HANDLER
              
              Dim invoice_hdr as P
              invoice_hdr = table.current(1)
              
              if Invoice_hdr.PD_Desc = "Delivery" .and. Invoice_hdr.Tax_location = "" then
              	dim msg as C
              	msg = "Tax Jurisdiction is blank"
              	msg = msg + crlf(2) + "Update customer shipping address to include a tax jurisdiction"
                  ui_msg_box("Error", msg)
              	
              	dim frm as P
              	frm = form.load("customer_frm","dialog")
              
              	dim cust_hdr as P{
              	cust_hdr = frm.table_get()
              	
              	dim cust_dtl as P
              	cust_dtl = frm:browse1.Table_get()
              	
              	dim query.description as C
              	dim query.order as C
              	dim query.filter as C
              	dim query.options as C
              	query.description = "blank tax jurisdiction"
              	query.order = "recno()"
              	query.filter = "unique_id = " + quote(invoice_hdr.cust_id)
              	dim hdr_indx as P
              	hdr_indx = cust_hdr.query_create()	
              
              	query.description = "blank tax jurisdiction"
              	query.order = "recno()"
              	query.filter = "Addr1 =" + quote(invoice_hdr.c_addr1) + ".and. Addr2 =" + quote(invoice_hdr.c_addr2) 
              	query.filter = query.filter + ".and. ST =" + quote(invoice_hdr.c_st) + ".and. zip=" + quote(invoice_hdr.c_zip)
              	ui_msg_box("",query.filter)
              	dim dtl_indx as P
              	dtl_indx = cust_dtl.query_create()	
              
              	frm.show()
              
              	hdr_indx.drop()
              	dtl_indx.drop()
              	
              	if is_object(frm) = .t. then 											     frm.close()
              	end if
              	
              end if
              END
              '-----------------------------------
              'Error handler
              '-----------------------------------
              ERR_HANDLER:
              	Dim err as N= error_code_get()
              	Dim msg as C= "Error # "+ err + crlf() + error_text_get(err)
              	msg = msg + crlf() + "Script: " + error_script_get()
              	msg = msg + crlf() + "Line #: " + error_line_number_get()
              	
              	ui_msg_box("Error", msg, ui_attention_symbol)
              	msg = ""
              
              	if is_object(frm) = .t. then 																									
              		frm.close()
              	end if
              
              	END
              Andrew

              Comment

              Working...
              X