1 (edited by rhyacm 2019-03-10 12:20:42)

Topic: Select item in combo box make do loop 2x

Hello,

It took me many hours to figure out why my do loop executed twice even it should be only 1.
It turns out that when searching by typing and click the item in combo box it will execute it twice so if i have loop script on change event it will execute twice.

what i want to accomplish:
- grid1 have the list of free item that customer can claim (invisible)
- combo box1 has the list of customer
- grid2 will be the list of items added from other buttons. if customer has free items in grid1 it will be automatically added here.

If i select a customer from combobox1, it will search item from grid1 using loop, if found, item will be added to grid2. All good but it go to the loop twice when typing then clicking on item. so if i have showmessage or other procedure to execute it will be executed twice. please see sample
how to fix this? thanks!

Post's attachments

Attachment icon grid loop.rar 294.62 kb, 286 downloads since 2019-03-10 

2 (edited by derek 2019-03-10 20:46:09)

Re: Select item in combo box make do loop 2x

Hi,
If I understand your question correctly, then I'm not sure why you need to use a script.
It seems that all you are wanting to do is filter tablegrid1 by customer which is a standard MVD search with no script required and the result can either be output to the same tablegrid (tablegrid1) or, as you are doing, to a separate tablegrid (tablegrid2).
Please have a look at the objects that I added to your project as an example.
Derek.

Post's attachments

Attachment icon grid loop 2.zip 338.39 kb, 347 downloads since 2019-03-10 

Re: Select item in combo box make do loop 2x

derek wrote:

Hi,
If I understand your question correctly, then I'm not sure why you need to use a script.
It seems that all you are wanting to do is filter tablegrid1 by customer which is a standard MVD search with no script required and the result can either be output to the same tablegrid (tablegrid1) or, as you are doing, to a separate tablegrid (tablegrid2).
Please have a look at the objects that I added to your project as an example.
Derek.

Hello derek

Thank you for response. yes you understand it correctly and your solution will work. I have seen this solution in other thread as example but i did not actually understand the combination of button and combo box thanks to you its clear for me. This means that if I select from combo box the button will be automatically triggered?
I will use this..
I think of scripting because there are lot of things i need to accomplish in this transaction like if the customer exist in Grid1 (Grid1.visible=False), after selecting  the customer from combobox there will be a message congratulating the customer and asking if he or she want to claim this prize now, if yes then items from Grid1 will be added to Grid2 if not nothing will happen, (user will add other items to grid2). Then later this items from Grid2 will be save to table together with additional information found on the Form1 (price, total amount, discount etc etc) but not necessarily existing in the Grid2 which I think of manually using insert query. But this give me idea of using invisible button that will be triggered to save other data or update rather than writing the query my self... im really new to visualdatabase and still evaluating the product...will buy this for sure.

4 (edited by derek 2019-03-11 12:05:49)

Re: Select item in combo box make do loop 2x

Hello,
The search button can either be manually clicked or automatically triggered (in which case I usually hide it).
In order for the search button to automatically trigger, you need to set the increm. Search property of form1.combobox1 to the relevant search button (form1.button1) - have a look at the screen capture.
Regards,
Derek.

Post's attachments

Attachment icon gridloop.jpg 244.52 kb, 178 downloads since 2019-03-11 

Re: Select item in combo box make do loop 2x

derek wrote:

Hello,
The search button can either be manually clicked or automatically triggered (in which case I usually hide it).
In order for the search button to automatically trigger, you need to set the increm. Search property of form1.combobox1 to the relevant search button (form1.button1) - have a look at the screen capture.
Regards,
Derek.

I see! nice info thanks again!