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 help revising OnPush event for a similar button

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

    #31
    Re: Need help revising OnPush event for a similar button

    Wanda:
    I am not sure which threads you are referring to, but it seems to me what you are trying to do is not all that complicated. If you wish to zip your file and tell me what you want to accomplish, I will work on it later.

    I do run complicated queries on my DB without any difficulties.

    Comment


      #32
      Re: Need help revising OnPush event for a similar button

      Gabriel,
      Unfortunately, I do not have time to strip the confidential data out of the db in order to zip and post it, as I am getting ready to go to my 2nd job right now.

      I may be taking next week off from this job, so that I can work on my website for my store. If I do, then I'll be back here on 8/7 and may be able to spend 4-5 hours more on this. I have another, huge project looming before me that I must start on on 8/7, as well, and this app is supposed to be completely done, distributed to the users, and I'm supposed to have the users trained on it.

      As you can see, I'm sinking fast - in spite of working 70-80 hours a week for 5+ months, now - which doesn't even count the property work I have to do in my "spare time", dealing with tenents, maintenance, upkeep, etc., I am not managing to successfully handle it all. At this rate, I'm going to have a stroke, soon - geeze! And, no, I didn't take it all upon myself. Most of it was thrown upon me by circumstances beyond my control - yet, if I don't "handle" it, I lose thousands of dollars. So, no, I can't just zip it and send.

      Thank you for listening!
      Wanda

      Comment


        #33
        Re: Need help revising OnPush event for a similar button

        Hi Wanda,

        I go away for a couple of days and look what happens. OK...

        For Gabriel's sake of understanding.. Wanda has a form (Quick_Screen_Menu) based upon a dummy table with only buttons, each button a specific query to the Site.set, and therefore each button generating a variable (vSiteSearch) that is the name of the Query in the Site form. The Site form Oninit event runs a Query specified by name with the vSiteSearch variable that is generated by Quick_Screen_Menu button. The Oninit event is conditional on entering the Site form from the Quick_Screen_Menu, that condition being met by the value of the FromForm variable= Quick_Screen_Menu also generated by the OnPush event of the Quick_Screen_Menu button. The Site OnInit event script is:

        Code:
        ' Site Form OnInit event
        	if FromForm = "Quick_Screen_Menu" then
        		GOTO RUNQUERY
        	else
        		GOTO FINISHED
        	end if
        RUNQUERY:
        
        'Turn off query in  in current form.
        	topparent.show_all()
        'Execute query from variable
        dim global vSiteSrch as C 
        evaluate_template("topparent.Run_Saved_Query("+quote(vSiteSrch)+")")
        FINISHED:
        OK, Wanda....
        I�m back to help, but I have to share with you a little frustration.
        Like Tom Crone wrote- If you are going to use code, then learn what it is doing and understand it. You can't just copy it.

        I thought it was clearly NOT RECOMMENDED you use the code in your old buttons since it contains redundant, unnecessary and confounding code,as follows:
        Code:
        'Are there matching records present in the table?
                       [COLOR="Red"] >>> here to next note unneccesary <<<<
        
        dim global tbl as P
        dim global qry as P
        dim global nrecs as N
        
        tbl = table.open("sites")
        tbl = table.open("buildings")
        
        query.description = "Search for matching records"
        query.order = ""
        query.filter = "trim(buildings->Capacity_Shelter)=\"Cap_30\""
        query.options = ""
        
                      >>> here to prior note unneccesary <<<<[/COLOR]
        nrecs= a5_get_records_in_query("buildings","Capacity_Shelter=\"Cap_30\"")
        
        IF (nrecs = 0) then
        
        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
        Unnecessary code. The a5_get_records_in_query() does it all for you. I was thinking you understood this, after Stan, Cheryl and me, and maybe others, wrote about this before.

        The SUCCESSFUL query strategy (I thought) we set up for you is one I thought you were going to continue (above). But, it appears you have chosen to copy/paste Xbasic code from your old buttons, which, be honest, you really don�t understand and are trying to use, instead of the action scripting buttons having two places that would need amending to change variable names and filters, to achieve the new query you would need. I say this and I can't get your latest query issue resolved either, with any approach.

        I want to use the revised code on another button (button2) on a different form to run a different query (Capacity_Shelter<30),
        Code:
        a5_get_records_in_query("buildings","Capacity_Shelter=\"Cap_30\"")
        should be:
        Code:
        a5_get_records_in_query("buildings","Capacity_Shelter<30")
        According to the database of yours I have, this field is numeric. There are 91 records that match that A5_query in the version I have. Many are bank fields.

        There are two problems I believe you are running into. One is that you have the Site_plus .set structure as Site 1:M Buildings and you are Querying the value of a Child table. While G.Gabriel was correct in the things he was writing, I cannot for the life of me get ANY Query, using the filters Flattenquery (), or Crosslevel() to perform reliably the Buildings->Capacity_Shelter = <something> table filter. I am at a loss. Higher powers than me are clearly needed.

        What you have at the bottom of your Sites Form is a Subform for the Child tables. Some tabs you have with Browses. Since Buildings is a 1:M, in order to see all the Child records for the Query regarding Buildings, you have to have an embedded Browse in there. Also, you do not have a unique identifier for each building. I�m thinking some of these other parameters you are going to want linked specifically to a specific building, yes?

        Although it does not complete your Query problem, I'm sending back your DB with this, and others to look at.
        1. I added the new button to the Quick Screen that generates the variable for the added new Operation (Query) SQShCap31N (Shelter capacity less than 31) that uses a flattenquery() filter. It does not work.
        2. I added a unique building number field to the buildings table and used this code (following) in the IW to generate the Building_ID as a combination Site_id and unique building number.
        3. I added the calculated field rule for the Building_id for future additions to the Building Table.
        4. I added an embedded browse to your Buildings subform so you could scroll through the MANY which are found with the Queries, hopefuly in the future by higher powers, �cause I can�t get the Set to filter for a query to the Child table. Sorry.

        Code:
        � creates unique Building Id numbers
        dim tbl as P
        dim endnum as N=0.01
        dim cycle as N=1
        dim priorid as N=0
        
        tbl = table.open("buildings")
        query.filter = ""
        query.order = "Site_ID"
        query.options = ""
        xi = tbl.query_create()
        
        tbl.fetch_first()
        while .not. tbl.fetch_eof()
        	chkid = tbl.Site_id	
        	if chkid <> priorid then
        		endnum = 0.01
        	else
        		endnum = endnum +.01
        	end if
        	tbl.change_begin()
        	tbl.Building_id = chkid + endnum
        	tbl.change_end(.t.)
        	priorid = chkid
        tbl.fetch_next()
        end while
        tbl.close()
        I hope somone can add some insight to this Child table query issue 'cause it would teach me something too. Don't give up, girl! I�ll hang with you�

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

        Comment


          #34
          Re: Need help revising OnPush event for a similar button

          Oh brother...!

          Mike: you are correct on echoing Tom's words of wisdom regarding codes..
          Here is another word of wisdom: almost everyone is so anxious to learn all they can learn about xbasic, xdlg ..etc and in the process they overlook, in my opinion, the single most important item: the design itself.

          If it was me, I wouldn't use all these "secondary interfaces" such as a form based on dummy table just to have buttons to run some searches...etc. Nonetheless, it appears that somebody spent so much time on this, so there is no need to re-invent the wheel.

          But to the issue of trying to query the child table:

          All Wanda needs is a reverse set and all these issues will go away!. Just make building table the parent, and sites a child and you are off to the races!

          Comment


            #35
            Re: Need help revising OnPush event for a similar button

            Good morning,
            I can't respond to this at length right now, as I have been off work from this job for a week, myself.

            As I recall, without having the time to dig into it today, I did everything I could think of to alter the code on a button in Quick Screen that you designed, Mike, to apply it to the other "search menus", but could not get it to work properly. It seemed as if I could copy/paste and just change the search name, etc. I don't recall why, although it is probably at the beginning of this thread.

            I believe at that point I started poking around with a couple other functions that I ran into in my extensive searching of Alpha's Help, which also was to no avail.

            I also recall suspecting that what I needed to change in the copy/pasted code should have been simple and easy to see, yet I still ran into trouble.

            I don't mean to offend at all, and I sincerely and honestly spent several hours trying to get it right. I in no way attempted to do anything other than your recommendations, yet you were suddenly gone, Mike, or had moved on to helping someone else or simply couldn't afford any more time on helping me - I didn't know which was the case. So, I forged ahead the best I could.

            Obviously I don't understand every function, command, code, snippet, or whatever the correct termonology is in the code you've worked up for me- yet I don't think that warrants you being frustrated with me or my efforts to follow your direction or the direction of others on this board. I'm just dense when it comes to different languages. Period.

            And now, it'll be a couple days probably before I can dive back in.

            Wanda

            Comment


              #36
              Re: Need help revising OnPush event for a similar button

              Dear Wanda,
              Sorry to cause you angst, it wasn't my intent. My intent was to try and get you to use Action Scripting as much as possible since that is what you are familiar with, and use XBasic for those events Action Scripting doesn't allow for. Onward?

              The picture has the Action Scripting for the OnPush event for the Quick Screen Menu buttons I created for you. What is created by this is for each button is two variables. The vSiteSearch variable can be considered a Selection variable. This variable selects which action (Query) to run. The FromForm variable can be considered a Director variable. It directs the conditional if-then statement in the Site form OnInit event to run or not run the query effected by the Selection variable-vSiteSearch. This process should allow you to produce all the buttons for any particular search in the Site form you want to create. Certain upscales using flattenquery() or other might be needed for some of the searches if queries are made to Child tables.

              To make a new button for a new query, these are the things that you need to do:
              1. Copy and Paste the Earthquake-Proof button
              2). Change the Button Name to be the next query your building.
              3). Change the value of the vSiteSearch variable (OnPush script action 1) to equal the <Query name> you will build (below) that this selection variable will run.
              3), Edit third action script event changing the filter for the A5_get_records_in_query () probe of the table (red section below) to be equal to the event you are wishing.
              Code:
              a5_get_records_in_query("sites","[COLOR="Red"]Equake=\"Y\[/COLOR]"")<>0
              4. Open Site form, build the Query you wish the button to run and save it with the same name used for the vSiteSearch variable in step (3).

              I thought the SQShCap31N (SiteQueryShelterCapacity31No) query was not working because it did not retrieve exclusively the records that matched the Query conditions. But it is doing what the Query is capable of with a 1:M Child table link through the Site_Id and that is retrieve records with that Parent Site_id which matched the Query condition, and thus because it is a 1:M pulling the whole group, one of the group matching the definition of the query.

              The last item at this time is that I added the Building_ID field and made the field rule to create this id number. With G. Gabriel and others assistance, I think the best is to set the Buildings>Building_id>Field Rules>Field Types to Calculated with the following expression:
              Code:
              SITE_ID+(TABLEMAX("buildings","site_id = "+SITE_ID,"building_id")-SITE_ID+.01)
              This will assure that if a building in the middle of a given Site_id sequence is deleted or removed, any new one added will not generate a duplicate number. But you may not want/need building_id at all.

              Don't hesitate to ask for help. I'll keep monitoring.

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

              Comment


                #37
                Re: Need help revising OnPush event for a similar button

                Good morning, Mike.
                Thank you for hanging in there with me...Your last post makes sense to me, and seems very similar to what I had tried before being gone a week. I'll be able to get back to it in a day or two...other piles are demanding my attention, currently.

                I'm anxious to work out these steps you've provided and get back to you! When these buttons are done, I'll be near completion for this project (then, time-allowed, I'll need to clean up and complete my POS at my store - an arduous task since I didn't design it from the beginning to where it is now...)

                You're a real rooper! (I still owe you a wine tasting tour - or 2 or 3!)

                Thank you,
                Wanda

                Comment


                  #38
                  Re: Need help revising OnPush event for a similar button

                  Hi Wanda,
                  A screenshot of your 2 or 3 forms would help, but I think I may have a function you can use from one of my apps that may help.

                  Tell me if I have got what you are trying to do right:
                  1. Your menu form is using a button to create a query and open a form to display the filtered records

                  2. On that filtered form you have buttons to open another form (Sites) that will be filtered on the capacity value the user selects.

                  Here is a function I've been using before I found the form.viewqueried() method. It will check if the Sites form is already loaded and if not, load it and run the query then show the results.

                  You will pass the parameters for your form name, the table name to be queried, the filter to use, and the sort order for the form, so that it will open with your query.

                  This example should be placed in your button script:

                  Ex: Q_frm("Sites","Buildings","Capacity_shelter=Cap_30","")
                  In this example no sort order is specified, so record number is used.

                  I am not sure of the source of the fields you are using, the above example assumes both fields are found in Buildings - which is probably not the case. So if the calling form is the source of Cap_30 field, then you can set a shared variable to the Cap_30.value and then use that variable in your filter expression so instead this is what you put in your button script:

                  Code:
                  dim shared vnCap as n
                  vnCap=Cap_30.value [COLOR=darkslateblue]'this is a field object on your calling form[/COLOR]
                  Q_frm("Sites","Buildings","Capacity_shelter = var->vnCap","")
                  Create a new global function and call it Q_Frm() and copy this code into it:
                  Code:
                   
                  FUNCTION Q_Frm as L(frm_name as C,tbl_name as C,q_filt as C,q_ord as C)
                  'My App Ex:
                  'q_frm("In Stock List","Yarn_Item","CUSTID = '"+get_custid+"'","YARNID")
                  dim frm as p
                  dim tbl as p
                  trace.writeln("' Query Form: "+var->frm_name)
                  frm = obj(frm_name)
                  if .not. is_object(frm) then
                   frm = :form.load(frm_name) 
                  end if
                  query.description = "Q_Form"
                  query.filter = q_filt
                  trace.writeln("' Q Filter: "+var->q_filt)
                  query.order = q_ord
                  query.options = "M" 'force to create a new query
                  idx = eval("frm:tables:"+tbl_name+".query_create()")
                  recs = idx.records_get()
                  trace.writeln("' Records found: "+ltrim(str(recs)))
                  if recs <1 then
                   cr = crlf()
                   msg = "No records were found that match your criteria"+cr
                   msg1 = "Do you want to display all records?"
                   msg_str = msg+msg1
                   response =  ui_msg_box("Query Result",msg_str,3+32)
                   select
                    case response = 2
                     'user cancelled
                     idx.drop()
                     frm.close()
                     goto ENDIT
                    case response = 6
                     'user wants to show all records 
                     idx.drop()
                   end select
                  end if
                  'frm.resynch() '{F5} works better for some reason
                  frm.show()
                  frm.activate()
                  sys_send_keys("{F5}")
                  ENDIT:
                  end
                  END FUNCTION
                  The filter probably needs to be more complex since the Sites table will need to add an expression for the linking value as well. Let me know what your field names are and we can work on the filter.
                  Last edited by MoGrace; 08-09-2006, 04:25 PM.
                  Robin

                  Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                  Comment


                    #39
                    Re: Need help revising OnPush event for a similar button

                    Hi Robin,
                    Thank you for your input and the time you've spent on it. I won't be able to get back to working on the app until next week. I'll first work with what Mike has sent, as he has stepped me through it from the beginning, and we're real close to nailing it all down. Without diving into it further at this time, your code may be very similar to his. Did you read the rest of the thread?

                    Mike, correction needed...you're not a real rooper, but rather a real Trooper! (Wonder what a rooper is...)

                    Thank you,
                    Wanda

                    Comment


                      #40
                      Re: Need help revising OnPush event for a similar button

                      W,
                      Rooper, trooper, it's all good...
                      I'll try and look into Robin's code for educational purpose. It doesn't at all resolve for me just reading it, so some playing with it will definitely be required.

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

                      Comment

                      Working...
                      X