Hot Topic (More than 10 Replies) Search Query for Mainform and Subforms (Read 1134 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Search Query for Mainform and Subforms
Mar 19th, 2013 at 4:36am
Print Post Print Post  
Simple Search and Universal Search are both very useful but that still do not search the subform fields. Is there anyway to search also the subform tableview forms along with the mainform for that simple word or words?
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Search Query for Mainform and Subforms
Reply #1 - Mar 20th, 2013 at 9:36pm
Print Post Print Post  
I was thinking about making a readonly field in the mainform. Since the important field in each subform (I have three of them) is description for search point of view, I can have description added, changed or removed that part of description in that readonly field on adding new record, changing the description field or deleting the record accordingly.  This way universal search and simple search should work for subforms as   far as description field is concerned. Do anybody see problem with that? Any suggestions?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Search Query for Mainform and Subforms
Reply #2 - Mar 21st, 2013 at 2:37pm
Print Post Print Post  
Hello Bharat,

It would add a bit of overhead to the file and increase the size of each parent record but it would accomplish what you are after and allow simple search to work on values stored in the subform.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Search Query for Mainform and Subforms
Reply #3 - Mar 21st, 2013 at 3:15pm
Print Post Print Post  
Thanks Ray for your feedback. I think the overhead will be still worth for having the ability to search both mainform and subforms using universal and simple search.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Search Query for Mainform and Subforms
Reply #4 - Mar 21st, 2013 at 9:11pm
Print Post Print Post  
Hello Bharat,

Looking at it now, It is going to be quite a lot of programming to maintain that description element on the Parent form.

Mark was brainstorming here in the office and came up with a way that may work for you depending on several things.

When you do a simple search are you looking for a single word or multiple words?
You say you want to search the description element of all 3 subforms, in addition to that, How many elements on the parent form do you really need to search for that data as well?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Search Query for Mainform and Subforms
Reply #5 - Mar 21st, 2013 at 10:28pm
Print Post Print Post  
Thanks Ray, I usually put single word for simple search as multiple words might pull out quite a few records. I also like to use Universal Search, with readonly description field on mainform, universal search should also work.  I have good 15 to 20 fields on the main form. I was thinking, While I add new record in the subform, it writes in that readonly field. If I make change on the description field of any of the subform, it will note down what was there before on element Entry event and assigned it to a variable and remove that part from readonly field on Element Exit event and add the new value. On Delete record of any subform, it will remove description value from the readonly field. Doesn't this cover all the different scenarios?
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Search Query for Mainform and Subforms
Reply #6 - Mar 22nd, 2013 at 1:25pm
Print Post Print Post  
Trying to maintain an element that contains the values for elements that appear on three subforms, each possibly containing dozens, if not hundreds, of records, sounds very difficult. You will need to continuously run through all of the subform records and rebuild the "read only" field. Trying to maintain the totality string on the parent form, without rebuilding it over and over again, is likely to be extremely difficult. If you have a lot of records in the subforms, it will be nearly impossible to determine the beginning point and end point of edits without also saving every original value in yet another globally static variable or element - one for each record in each subform.

I would recommend instead, that you place a button on the parent form in search that brings up a @PromptForUserInput and asks the user for a search string. It then fills in the search spec in the appropriate elements in the subforms (and in the main form, if any elements there are relevent) and sets the search mode to "or" instead of "and" and kicks off the search. If need be, you can preface and concatenate ".." onto the string. While not as flexible as Universal Search, this will allow you to easily search all of the values in all of the subform records for one or more elements per subform / parent form.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Search Query for Mainform and Subforms
Reply #7 - Mar 22nd, 2013 at 6:59pm
Print Post Print Post  
Thanks Mark. I see your point. Do you think any program retrieval could achieve the same results as Simple and Universal search on mainform and subforms at the same time?
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Search Query for Mainform and Subforms
Reply #8 - Mar 22nd, 2013 at 7:22pm
Print Post Print Post  
I'm not sure what you are asking.

I believe you can meet your requirement using some automation in SBasic. Even if you need to search all of the elements on the main form, plus some on the subforms, it is simply a matter of changing the mode (from "and" to "or") and using filling out those elements on the retrieve spec. Basically, you are automating what you would do by hand.

I looked into getting Universal Search to work with subforms. It doesn't look too difficult. I will probably add it as a feature to Sesame 3.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Search Query for Mainform and Subforms
Reply #9 - Mar 22nd, 2013 at 8:02pm
Print Post Print Post  
Quote:
I looked into getting Universal Search to work with subforms. It doesn't look too difficult. I will probably add it as a feature to Sesame 3.


Thanks Mark. That will be great.

Quote:
it is simply a matter of changing the mode (from "and" to "or") and using filling out those elements on the retrieve spec. Basically, you are automating what you would do by hand.


Manually one can choose Any or All from the command tree, but I am not sure how it is used in the code while automating, the default is "All" (meaning meeting all criteria) and that will have to be changed to "any".
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Search Query for Mainform and Subforms
Reply #10 - Mar 22nd, 2013 at 8:55pm
Print Post Print Post  
Bharat_Naik wrote on Mar 22nd, 2013 at 8:02pm:
Manually one can choose Any or All from the command tree, but I am not sure how it is used in the code while automating, the default is "All" (meaning meeting all criteria) and that will have to be changed to "any".


Use SelectTreeItem to set the mode to "Meet any Restriction" (or "Or") before using SelectTreeItem to launch the search.


  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged