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

open child browse w/ no records - redux

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

    open child browse w/ no records - redux

    A couple of recent threads on this, and I have just run into it as well. The only problem is that when a form with embedded browse is opened with no existing records, then pressing {ESC} displays all of the records. By that I mean that the base query is lost. If other child records exist for the parent, then {ESC} does not lose the base query.

    Why is possible to remove the base query in a form with embedded browse, while base query always stays in a plain form?

    Attached is a sample database. The People(n) forms are the parent. A button displays the child records in a form (Phone) with embedded browse. The general approach in the button is this.
    Code:
    t = table.current()
    vPersonid = t.person_id
    
    query.filter = "person_id = " +quote(vPersonid)
    query.order = ""
    
    DIM layout_name as c 
    layout_name = "Phone"
    'varP_Phone = :Form.viewqueried(layout_name,query.filter, query.order ,"hidden-dialog","Center","Top")
    '-------------------------------------
    'revised so form will show even if no current phones exist.
    varP_Phone = form.load(layout_name,"dialog","","Center","Top")
    varP_Phone.basequeryrun(query.filter, query.order)
    
    varP_Phone.show()
    People6 form is the last resort. It handles the {ESC} and records are entered correctly, but is not the user interface I want. I also don't want to use OnKey to supress the {ESC} since it has legitimate use to cancel a record.

    Let's say that People4 is the form I want to use. Go to the last record (no child phones), press the Edit Phones button. It displays a form with embedded browse, no records, and in data entry mode. If you do data entry, all works perfectly. OTOH, if {ESC} is pressed, then phones for the other parent records are displayed. This is what I want to avoid.

    People5 is basically the same thing, but I put the basequeryrun in OnInit of the Phone2 form. same result.

    Stan Mathews suggests adding a blank record before the form is displayed. I don't want that. If the user ultimately does not enter a record, I don't want a blank hanging around.

    (People1-3 forms are the approaches that give the error if no child record exists, so of no use here.)

    Bill.
    Attached Files

    #2
    Re: open child browse w/ no records - redux

    Bill,

    After pack the tables, works fine here on your form 4,5 & 6.

    Comment


      #3
      Re: open child browse w/ no records - redux

      John,

      With form People4 displayed, are you saying that on person id 103 (if it still has 0 child phones), that Ctl-P displays the Phones form with no records from persons 101 or 102?

      If so, what v11 build are you using?

      Bill.
      Last edited by Bill Parker; 03-20-2013, 09:36 AM. Reason: wrong form name

      Comment


        #4
        Re: open child browse w/ no records - redux

        Bill,

        Don't know if I suggested adding a blank record so much as saying it was the only way. So much for semantics.

        What behavior do you see if you make the close button first in the tab order on the phone form so the browse doesn't get focus unless deliberately? Acceptable? You'll still see all records if the user begins a new record but abandons it with {ESC} but that could be handled.
        There can be only one.

        Comment


          #5
          Re: open child browse w/ no records - redux

          Stan, you are right that changing tab order solves the immediate problem when using Ctl-P, but putting focus on browse and pressing {ESC} still removes the base query (or that appears to be what is happening).

          If adding a blank record is the ONLY solution (other than the People6 form approach), then it is time for an enhancement request for base filter to apply to browse (as it appears to apply to form) even if 0 records match filter.

          Another question. I add the linking key in Phones record using a field rule. I thought I read of a way to do this automatically when a base query was in effect, but I don't find anything in the documentation.

          Bill.

          rats - After writing the above it occured to me to use People5 form and apply the base filter to browse1 in Phones2 instead of applying it to the form. But that made no difference.
          Last edited by Bill Parker; 03-20-2013, 10:09 AM. Reason: tried something new.

          Comment


            #6
            Re: open child browse w/ no records - redux

            Ignore, I misread as adding the linking field.
            There can be only one.

            Comment


              #7
              Re: open child browse w/ no records - redux

              Bill,

              Yes. I am on 103, bob's record from People4 and the child are blank records except when I clicked the close button, it created (saved) the FK value.

              Comment


                #8
                Re: open child browse w/ no records - redux

                Bill,

                I still have v9 and I am not able to read your button's query but I write this way whenever open a 2nd form.
                Code:
                t = table.current()
                vPersonid = t.person_id
                
                query.filter = "person_id = " +quote(vPersonid)
                query.order = ""
                
                DIM layout_name as c 
                layout_name = "Phone"
                
                'revised so form will show even if no current phones exist.
                
                'Check the records from table.
                dim tbl as p
                tbl = table.open("phone")
                qry = tbl.query.create()
                rcd = qry.records_get()
                If rcd > 0 then
                     'Show me form
                     varP_Phone.basequeryrun(query.filter, query.order)  
                    varP_Phone.show()
                else
                    form.view("phone")  'See help for detail
                    'new record
                    'add default "PK" value before open a form
                end if
                tbl.close()

                Comment


                  #9
                  Re: open child browse w/ no records - redux

                  Bill, I think I have figured it out.

                  1. In an embedded browse, if entering a NEW record, by default Escape cancels the entire record, not the current field entry in the browse buffer.
                  2. If editing a saved record, it seems to work as advertised.

                  SO:
                  here was my solution - In phone3(or any of the forms) I mad a global variable
                  dim global pid as c
                  pid=id.value 'the value in the current record

                  then, in Phone, in the onkey event, I put this code:

                  Code:
                  dim global pid as c
                  if parentform.Records_Get()=0 'the only time this is an issue
                  	if a_user.key.value="{esc}"
                  		a_user.key.handled=.t.
                  		if a_user.key.event="down"
                  			response=msgbox("Note","Cancel Changes?",292)
                  			if response=6
                  				CONTROL_BROWSE1.cancel()			
                  				parentform.cancel()
                  				parentform.BaseQueryRun("person_id=var->pid","type")
                  				end 
                  			end if
                  		end if 
                  	end if 
                  end if
                  Cole Custom Programming - Terrell, Texas
                  972 524 8714
                  [email protected]

                  ____________________
                  "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                  Comment


                    #10
                    Re: open child browse w/ no records - redux

                    Martin, this is close. Both People3 and 4 use the Phone form, so test can be on either. The problem for me is that pressing Ctl-P from a parent with no child records still displays all phones. Pressing {ESC} (now on the Phone form) then hides those phones because the base filter is re-applied by OnKey.

                    A curious display artifact is that when the Close button is pressed on the Phone form, all phone records appear briefly in the browse as the form is closing.

                    Bill.

                    Comment


                      #11
                      Re: open child browse w/ no records - redux

                      Problem solved. Cian had the good sense to ask why I was not basing my Phone form on the set vs. the phone table. Duh. The form still just has the embedded phone browse and no parent fields. But now the base filter can be at the parent level, and there is always 1 parent record that will be in the query. And now the browse works as I would expect regardless of the number of phone records.

                      Attached is a revised sample database. People7 is the way it now works. Due to removing a field rule, the other People forms no longer provide the linking key to phone. So just test with People7.

                      Cian pointed out that
                      count = varP_Phone.basequeryrun(query.filter, query.order)
                      returns a count of records (or 0) even though the return parameter is not mentioned in the documentation. That may be useful to some.

                      I still see no advantage to having a 'special case' for 0 records in query, which is treated as an invalid query as far as form.viewqueried(). But that is the way it will stay.

                      Bill.
                      Attached Files

                      Comment

                      Working...
                      X