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

Need to return to same form after query returns 0 recs

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

    Need to return to same form after query returns 0 recs

    I have a couple forms that are populated with OnPush event buttons - no fields. These buttons run their search and display the resulting records in a data entry form called Sites.

    When the results of any given search return 0 records, I get the message that no records were found. When I click OK in this message box, focus is given to the Control Panel. I want the focus to re-open the form where the search buttons reside, instead. How do I accomplish this?

    Thank you,
    Wanda

    #2
    learn a5_get_records_in_query()

    Wanda,

    I recommend strongly that you learn the a5_get_records_in_query() function. It has been of great use to me. It returns the number of records in the query. I use this as a condition in a Action Script Branch event alot to direct the Action in the event records are not found and not wanting the user to have to deal with the message window.

    Mike W.
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

    Comment


      #3
      An example

      W,

      I found an example for you (attached).

      Mike W
      Mike W
      __________________________
      "I rebel in at least small things to express to the world that I have not completely surrendered"

      Comment


        #4
        Uhm, okay. I would love to - but I need a clue as to where it would go. I don't know code very well at all and get 99% of the results I need from using Action Scripting.

        That said, with your hint, it is greek to me as to why the function you mention would return to a specific menu when no specific menu is even mentioned in your code. How in the heck does that work? How does it know which menu to go back to?

        Also, maybe you could point out where your code should go. Here is the code as converted from action scripting.
        Thank you,
        Wanda
        'Close Quick Screen
        DIM mode as c
        mode = parentform.mode_get()
        'If the form is in Enter or Change mode, first save the changes before closing the form
        if mode = "ENTER" .or. mode = "CHANGE" then
        parentform.commit()
        'Check to see if the record was successfully saved
        if parentform.mode_get()<>"VIEW" then
        ui_msg_box("Unable to save your changes","Please correct and save, or discard your changes", UI_STOP_SYMBOL)
        end
        end if
        end if
        'Close the form
        parentform.close(.f.)

        'Opens sites and runs saved query on Equate
        query.filter = "trim(Sites->Equake)=\"Y\""
        query.order = ""


        'Open the layout_type showing just the records that satisfy the filter
        DIM Shared varP_Sites as P
        DIM layout_name as c
        layout_name = "Sites"


        dim tempP as p
        'Get pointer to existing window. In case layout_name is qualified with a dictionary name, extract up to first @. In case formname has spaces, normalize it
        tempP=obj(":"+object_name_normalize(word(layout_name,1,"@")))
        'Test if pointer is valid
        if is_object(tempP) then
        'Test if pointer refers to a form or browse
        if tempP.class() = "form" .or. tempP.class() = "browse" then
        'Apply the query to the form or browse as the Base query. (this means that
        'the user cannot turn the query off, only add to the query)
        tempP.BaseQueryRun(query.filter,query.order)
        'then activate the already open window
        tempP.activate()
        else
        'Window is not already open, so open it
        varP_Sites = :Form.viewqueried(layout_name,query.filter, query.order )

        end if
        else
        varP_Sites = :Form.viewqueried(layout_name,query.filter, query.order )

        end if

        Comment


          #5
          Hi Mike,
          Thanks for the example. I see how it works for your situation, I think. If you did not create your own message that says it DID or DID NOT find records, would those searches resulting in no records found return the user to the control panel?

          In my situation, the search button is on one form, and searches within a different form. I need focus to return to the form where the button is if no records are found in any given search.
          Thank you,
          Wanda

          Comment


            #6
            Originally posted by Wanda Tucker
            Hi Mike,
            Thanks for the example. I see how it works for your situation, I think. If you did not create your own message that says it DID or DID NOT find records, would those searches resulting in no records found return the user to the control panel?

            In my situation, the search button is on one form, and searches within a different form. I need focus to return to the form where the button is if no records are found in any given search.
            Thank you,
            Wanda
            Are you hiding the control panel from your users, leaving yourself a passworded button to get to the control panel when needed? In this scenario there is no control panel for them to return to when no records are found. The user should automatically be returned to the calling form.
            There can be only one.

            Comment


              #7
              Hi Stan,
              No, since I'm still developing the app I have not hidden the control panel, yet.

              I assumed that the control should go back to where it was executed unless otherwise instructed, but it doesn't. Is it going to the control panel because it has no clue where else to go?
              Thank you,
              W

              Comment


                #8
                Originally posted by Wanda Tucker
                Hi Stan,
                No, since I'm still developing the app I have not hidden the control panel, yet.

                I assumed that the control should go back to where it was executed unless otherwise instructed, but it doesn't. Is it going to the control panel because it has no clue where else to go?
                Thank you,
                W
                Yep.

                It might save you some headaches and needless manipulation of the interface to proceed with hiding the control panel and observe the behavoir that you will face later anyway.
                There can be only one.

                Comment


                  #9
                  Tables not Forms

                  In my situation, the search button is on one form, and searches within a different form. I need focus to return to the form where the button is if no records are found in any given search.
                  Wanda,

                  The function looks for records in a table based upon a filter. This filter would be the same as that used in your search. Think of the function as a 'probe'. Using this function it can probe the table that this second form is based on without having to open the second form. If the 'probe' returns a value >0, have the script open the form and execute the query. If the 'probes' returns a value of 0, then go nowhere and maybe throw up a message 'no records'. There does not have to be a 'return' because you haven't shifted focus anywhere.

                  Mike W
                  Mike W
                  __________________________
                  "I rebel in at least small things to express to the world that I have not completely surrendered"

                  Comment


                    #10
                    Wanda,

                    It appears you are closing the form prior to running the query and loading the new form:

                    'Close Quick Screen
                    I would add the following code, prior to closing your quick screen:

                    Code:
                    'Are there matching records present in the table?
                    dim global tbl as P
                    dim global qry as P
                    dim global nrecs as N
                    
                    tbl = table.open([COLOR=Red]table_name[/COLOR])
                    
                    query.description = "Search for matching records"
                    query.order = [COLOR=Red]order_name[/COLOR]
                    query.filter = [COLOR=Red]filter_name[/COLOR]
                    query.options = ""
                    qry = tbl.query_create()
                    
                    nrecs = qry.records_get()
                    IF (nrecs = 0) then
                    qry.drop()
                    ui_msg_box("Null Query","There are no matching records in this search, unable to proceed" ,UI_INFORMATION_SYMBOL)
                    tbl.close()
                    end        'If there are no matching records, script ends here
                    
                    else
                    Note the 'red' text in the above code. You would need to substitute those with your table, filter, order enclosed in quotation marks "".

                    And then at the end of your code, after:

                    Code:
                         end if
                     else 
                         varP_Sites = :Form.viewqueried(layout_name,query.filter, query.order )
                     
                     end if
                    Add the following lines of code to end the 'Are there matching records present in the table? when there are matching records:

                    Code:
                    end if
                     xbasic_wait_for_idle()
                     tbl.close()
                    Cheryl
                    #1 Designs By Pagecrazy
                    http://pagecrazy.com/

                    Comment


                      #11
                      Hi Cheryl,
                      How do you whizzes create code this quickly?! I'm always impressed with the responses like this that I get - and you're all so helpful. Where would I be without you?!

                      Okay - I'm printing out your suggested coding and will see what I can do...am leaving in an hour, so if I don't get it, I'll be back tomorrow.

                      Thanks again, Cheryl and everyone :)
                      Wanda

                      Comment


                        #12
                        Sorry, Mike...didn't mean to ignore your last suggestion. If I went that route, wouldn't I end up with the Quick Screen menu being left open after each search button is pushed?

                        Also, I don't see how the query could even look for the records if the table and form aren't even opened...so, how could the query be run, and open the form only if records are found? I'm seriously confused, now...maybe that's a beauty of code - that code can make things happen even without the table being opened...Lord knows. I HATE CODE! It just never makes much sense to me...guess I'm like that guy with the high IQ who posted his frustrations - except that I think my IQ is pretty normal...

                        Okay, I'm done. Gonna work on Cheryl's code, now.

                        Thanks again!
                        Wanda

                        Comment


                          #13
                          Originally posted by Wanda Tucker
                          Also, I don't see how the query could even look for the records if the table and form aren't even opened...so, how could the query be run, and open the form only if records are found?
                          Several alpha functions, not code, process records in a table without you having to open the table. Tablesum(), dbsum(), and the corollary count, avg, etc. are some of the more common ones. You specify the table name as one of the parameters and Alpha does the work for you.

                          Description

                          The A5_GET_RECORDS_IN_QUERY() function returns the number of records in the specified table or set that satisfy a query expression.
                          I don't imagine you need to understand how it does this than you need to understand how the f_upper() function capitalizes the first letter of a character expression. All you do with f_upper() is specify the character string. A5_GET_RECORDS_IN_QUERY() is a little more complicated because you have to specify the query filter expression, but do't let that stop you from trying.

                          Mike has given you a nice example of using the output of the A5_GET_RECORDS_IN_QUERY() function to branch in action scripting. Well worth time studying when you have the time.
                          There can be only one.

                          Comment


                            #14
                            Table not found...why?

                            Hey Cheryl, Stan, Mike,
                            I've incorporated Cheryl's code, and the first error I get is that it can not find the table to open.

                            Yes, I double checked the spelling...here is the beginning of the code, up to Line 10:

                            'Date Created: 23-May-2006 10:40:48 AM
                            'Last Updated: 23-May-2006 10:40:48 AM
                            'Created By : tuckerw
                            'Updated By : tuckerw
                            'Are there matching records present in the table?
                            dim global tbl as P
                            dim global qry as P
                            dim global nrecs as N

                            tbl = table.open(sites)

                            Comment


                              #15
                              Okay, Stan. Thank you for your encouragement...where do you get your patience? I'll work with it tomorrow :)
                              Wanda

                              Comment

                              Working...
                              X