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

Help on how to display found records on subform

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

    Help on how to display found records on subform

    Hello,

    I have attached a sample app which i try to get working.

    I have a form with a subform on it. I want the user to enter a number to search for and push the search button.
    If that number exists in the database the subform is shown and the user should be able to update the record.
    If the number is not found he gets an error message.

    I managed to get it running but i think i fire a query event two times ?

    The following is the code i use in the onpush event:

    Code:
    dim tbl as P
    dim Q as P
    dim nrecs as N
    dim vGreffeuniek as C
    
    if searchnumber <> "" then                                        ' If number to search on is filled in
                   
    	vNumber = trim(searchnumber)
                   
       tbl = table.current()
       query.description = ""
       query.order = ""
       query.filter = "Number = " + vNumber
       query.options = ""
       Q = tbl.query_create()
        
       nrecs = Q.records_get()
       if nrecs = 0
         Q.drop()
         ui_msg_box("Error","Number "+trim(str(searchnumber))+" not found !")
         searchfield.activate()
       end
    	end if
    	
    	' if record is found then i want to check on the state
    	' if state is "V" or "G" then a messagebox should appear saying status is not OK
    	' if state is "Q" or "K" then the record should be shown in the subform and the user should be able to edit it
                  
       
       ' Searchform.QueryRun("Number = " + vNumber)                   ' This command shows the correct record but this way the query is executed two times ??
       Subform1.show()
    
    else
    	ui_beep(UI_EXCLAMATION_BEEP)
       searchfield.activate()
    end if
    I also want to check on the status field of the found record before showing it to the user but i dont know how to do this?
    I have put some comments in the app to explain better what i mean....

    thank you for your experienced help !

    Olivier

    #2
    Re: Help on how to display found records on subform

    In your table1 you have two instances of number 1 - if you search for number 1 then the code is going to return two instances of number 1. I deleted the duplicate record and the code only runs once for all numbers.

    Haven't looked at your second question yet - but will get to it.

    Tom

    Comment


      #3
      Re: Help on how to display found records on subform

      Oh, that was not ment to be. I changed that number to 6 and reuploaded the zip archive...

      For now when you push the search button it searches whether the input number exists and if so it displays the subform. But not the correct record is displayed on the subform!
      I have put a line in comment in the code which has a command that does show the right record but i think this way i run a query two times to get to the wanted results.

      When the users presses the cancel button it should cancel changes, hide the subform and activate the search button... i do not get it to do this...

      Comment


        #4
        Re: Help on how to display found records on subform

        Try this new zip file

        Review the xbasic code for the search button

        1. added messages that you wanted if a certain status was no okay. Had to open the table, fetch the record and then read the status value and compare it to "V" or "G" and if it matches give a message, if not open subform.

        2. fixed the cancel button. (it is now on the main form - I hid the buttons on the subform - but you can delete them if you like.) It now cancels the changes and hides the subform and then refresh the topparrent layout with topparent.refresh_layout()

        3. Again used the open table to fetch the record and show it on the subform. Reason record was not correct there was no code to set the record to the current record - added crec=current record then used tbl.fetch_goto(crec) to get that record. Then used the topparent.refresh_layout() to update the record in the subform. This is the same code that checks for a bad status.

        4. By reviewing the xbasic on the search button, you will be able to add more to the messages etc.

        Hope this is what you want

        Tom Baker

        Edit. Just a question, why are you using a subform - why not just the "searchsubform1" with a search button that would find the record and then display it. Just didn't understand.
        Last edited by Tbaker; 07-21-2008, 03:58 PM. Reason: forgot a question

        Comment


          #5
          Re: Help on how to display found records on subform

          Thank you Tom for your effort, i'll look into the code after i've taken my wife for a sunset walk along the beach ;-) It's 17 deg Celcius in summer (Belgium, http://maps.google.be/maps?utm_campa...&utm_term=maps) and we'll be blown of the beach but it gives you a very healthy feeling! For tomorrow they expect better weather....

          I use a subform and the search button on the main form because I want to present the user only with a search field and button and only show record details if present for that number. Dont want to confuse the user.
          Can I achieve the same result without using a subform ? How do I hide all fields at one time ?

          thank you again for your kind replies,

          Olivier

          Comment


            #6
            Re: Help on how to display found records on subform

            Super Tom !

            That works just like i wanted it to, thanx so much for your help.

            Just for me to understand:

            - the tbl.query_create command executes the query in the script but does not move the selection to the found record ?
            - we then retreive some values with records_get (no records) and current_record (the first found record by the query?)
            - then we move the selection to this current_record in the query that executes within the script so the form displays the right record ?

            please correct me if im wrong...

            going to take some sleep now, Olivier

            Comment


              #7
              Re: Help on how to display found records on subform

              Olivier

              Right

              You had asked whether you could do all this with a single form - yes you can, however it would require a lot of code to hide fields then show fields. If you have a table with a lot of fields, the sub form works fine but you could also use conditional objects. You could review conditional objects in the help file as well as sub forms.

              I put the buttons on the form because they react better. If you want you could hide the buttons in design properties and then if the status is okay you could show the buttons. button#.hide or button#.show().

              Hope you enjoyed your walk on the beach.

              Tom Baker

              Edit: Here is a zip file that does what you want. It gives the user just a field to enter a number and a button (search) to look for that number in the table. If the status is okay, the subform will show with the two buttons save and cancel at the bottom (they are still on the main form). You can save any edits or you can cancel any changes. If on the other hand the status is not OKAY, then the message box will show and when you push the okay button on the message box, it will give focus back to the main form in the searchfield for another try and the buttons save and cancel will hide until the next search that is status okay.
              Last edited by Tbaker; 07-21-2008, 07:04 PM. Reason: added a zip file

              Comment


                #8
                Re: Help on how to display found records on subform

                thanx tom, i've already implemented it in the app and it works great !! thanx!

                Comment


                  #9
                  Re: Help on how to display found records on subform

                  Originally posted by olivier View Post
                  For now when you push the search button it searches whether the input number exists and if so it displays the subform. But not the correct record is displayed on the subform!
                  Olivier,

                  Going back to your earlier example, this slight change makes the subform display the record properly.

                  Code:
                  'Date Created: 21-Jul-2008 03:22:11 PM
                  'Last Updated: 21-Jul-2008 03:38:10 PM
                  'Created By  : ozeegers
                  'Updated By  : ozeegers
                  dim tbl as P
                  dim Q as P
                  dim nrecs as N
                  dim vGreffeuniek as C
                  
                  if searchnumber <> "" then                                        ' If number to search on is filled in
                                 
                      vNumber = trim(searchnumber)
                                 
                     tbl = table.current()
                     query.description = ""
                     query.order = ""
                     query.filter = "Number = " + vNumber
                     query.options = ""
                     Q = tbl.query_create()
                      
                     nrecs = Q.records_get()
                     if nrecs = 0
                       Q.drop()
                       ui_msg_box("Error","Number "+trim(str(searchnumber))+" not found !")
                       searchfield.activate()
                     end
                      end if
                      
                      [COLOR=Blue][B]Searchform:subform1.resynch()[/B][/COLOR]
                     Subform1.show()
                  
                  else
                      ui_beep(UI_EXCLAMATION_BEEP)
                     searchfield.activate()
                  end if
                  In Tom's example, he uses this line: tbl.fetch_goto(crec)
                  which seems to be redundent (I think it is forcing the subform to display the record that the query already retrieved). The query has already fetched the correct record. You just need to resynch the subform. Tom's method may work fine, but strictly speaking it is not "correct", whereas resynch() arguably is "correct". -My 2-cents.
                  Peter
                  AlphaBase Solutions, LLC

                  [email protected]
                  https://www.alphabasesolutions.com


                  Comment


                    #10
                    Re: Help on how to display found records on subform

                    Peter

                    I just saw your post and the yoke is on me - the table was already opened and the record already fetched - You are right.

                    There is a little more to the code also - Olivier wanted to trap the value of the status field and post a message if it didn't equal certain status - that is where the original tbl.fetch_goto() was used - not to refresh the layout but to make sure the record was the current record for the test.

                    Here is the code with the addition that you don't have in your code - and with your recommendation (right on) it does not fetch the record.

                    Code:
                    dim tbl as P
                    dim Q as P
                    dim nrecs as N
                    dim vGreffeuniek as C
                    
                    if searchnumber <> "" then                       
                    	vNumber = trim(searchnumber)
                                   
                       tbl = table.current()
                       query.description = ""
                       query.order = ""
                       query.filter = "Number = " + vNumber
                       query.options = ""
                       Q = tbl.query_create()
                        
                       nrecs = Q.records_get()
                       crec=current_record()
                       if nrecs = 0
                         Q.drop()
                         ui_msg_box("Error","Number "+trim(str(searchnumber))+" not found !")
                         searchfield.activate()
                       end
                       
                    	end if
                    	             
                    	[COLOR="Blue"]'tbl.fetch_goto(crec)  'commented out this line it is redundant[/COLOR]
                    	if tbl.status="V" .or. tbl.status="Q" then
                    		subform1.hide()
                    		button2.hide()
                    	    button3.hide()
                    	    
                    	    
                    		topparent.refresh_layout()
                    		msgbox("",tbl.status+" Status is not okay")
                    	    
                    	    q.drop()
                    	    searchfield.activate()
                    	    topparent:searchfield.text=""
                    	    vNumber=""
                    	    
                    	    end
                    	end if
                    	
                    	
                    	' if record is found then i want to check on the state
                    	' if state is "V" or "G" then a messagebox should appear saying status is not OK
                    	' if state is "Q" or "K" then the record should be shown in the subform and the user should be able to edit it
                       topparent:button2.show()
                       topparent:button3.show() 
                       vnumber=""     
                       topparent:searchfield.text="" 
                       searchfield.activate()    
                       Subform1.show()
                       
                       subform1.refresh_layout()
                    
                    else
                    	ui_beep(UI_EXCLAMATION_BEEP)
                       searchfield.activate()
                    end if
                    Thanks

                    Tom

                    Comment


                      #11
                      Re: Help on how to display found records on subform

                      Originally posted by Tbaker View Post
                      There is a little more to the code also - Olivier wanted to trap the value of the status field and post a message if it didn't equal certain status - that is where the original tbl.fetch_goto() was used - not to refresh the layout but to make sure the record was the current record for the test.
                      Yes, I saw your other code. I was merely commenting on the query and pointing out the issue was not of being on the correct record (which was the case), but on refreshing the layout to display it.
                      Peter
                      AlphaBase Solutions, LLC

                      [email protected]
                      https://www.alphabasesolutions.com


                      Comment


                        #12
                        Re: Help on how to display found records on subform

                        Originally posted by olivier View Post
                        If that number exists in the database the subform is shown
                        I guess this is (although I didn't read the whole thread) a continuation to your other thread, ref: onkey.

                        I think you are going about this the wrong and hard way.
                        Forget about onkey (it's not a desirable event anyway).
                        Put your subform in a conditional object and make the condition based on the expression:
                        exist()

                        Or even better:
                        In the OnChange event of the searchfield:
                        If exist(........)
                        subform1.show()
                        else
                        subformi.hide()
                        end if
                        Last edited by G Gabriel; 07-22-2008, 02:26 PM.

                        Comment


                          #13
                          Re: Help on how to display found records on subform

                          This is fantastic information but would there be a way to accomplish what you've done (setting up a search) using action script instead since I'm not so great at xbasic yet?

                          What I'm doing is allowing my client to search by dropdate or job number. The dropdate is just there in case they need to browse that date to find the job.

                          When the query finds the job, all the data on the tabs will come up. I've attached a print screen of what I'm trying to accomplish
                          Up and coming Alphaholic ;)

                          Comment


                            #14
                            Re: Help on how to display found records on subform

                            Elena

                            I have attached a zip file, which might help you.

                            I based it soley on you thumbnails but there are many ways you can accomplish what you want.

                            Everything that is done on the form is in action scripting (not xbasic).

                            There is a form just as you showed in the thumbnail with three tabs - the first tab Work Order has a field vc_dropdate (the first blank field) which has an onchange event. You enter the drop date you want searched and then press enter. The browse will then show only those drop dates (there are three dates in the table 10/27/08 10/28/08 and 10/29/08.) I also placed a button below that "find drop date" which does the same thing. There is a second button on the form which is Find clientjobno. When pressed an dialog box appears asking for a clientjobno . You can either enter a job number from the browse below or click on the down area in the field which will show you a listing of all client job numbers in the table.

                            The second tab just shows the information about the clientjobno that you selected in a form - the third tab just shows the information in a browse.

                            Again, there are many ways that you can do this - but that depends on how you want to show your information. One was would be to have an event on the browse rowdoubleclick event to select the clientjob number.

                            There are two queries in the operations section q1 to find dropdate and q2 to find clientjob no. They are also in action scripting.

                            The thing here is that this was all done with action scripting not xbasic.

                            You will probably get other replies on other ways to do this which should help you decide on which way you would like to continue.

                            FWIW

                            Tom Baker

                            Comment


                              #15
                              Re: Help on how to display found records on subform

                              Wow! Thanks so much Tom. This is a great help!
                              Up and coming Alphaholic ;)

                              Comment

                              Working...
                              X