Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Appropriate place to Put Select-Sql 1

Status
Not open for further replies.

alisaif

ISP
Apr 6, 2013
418
AE
Hi,

I have two tables 1. Customer and 2. Location. Customer master contains Customer code,name, payment terms etc.. whereas, location contains customer Code, multiple locations, addresses and contact nos.

In data entry entry users put customer code, name displays and then cursor jump to a combo box which contains multiple location using the following sql:

Select location from customer where pcode = mpcode into cursor tmpCust order by Location. && mpcode is a variable for customer code

Now, where to put this SQL in lost focus event of text box of Customer code or Got focus event of the combo box of location. Because sometime I don't know what happened I receive an error and combo box disappear.

Please suggest

Thanks

Saif

 
If working with dynamically loaded data in forms, the most sesitive control is the grid, the second most is the combobox.

If you change data the combobox should display, you need to temporarily set the combobox.rowsourcetype=0 (no rowsource) and rowsource="", then do your query, then bind the combobox again, by setting back rowsrource and rowsourcetype.

If you do that, it doesn't matter much, in which exact event. Both events you mentioned are wrong, anyway, because lostfocus is even occurring after the next control was triggered with it's WHEN event, and gotfocus is also too late, because then the control already got the focus and should have the data it displays.

I consider using the comobobox events, because you might later extend the filtering of data to more than just the one textbox. The ideal event would be the Combobox.When() event. You might even prevent the focus to come to the combobox in that event, if the query results in no data, for example, or if filter values conflict with each other or for whatever other reason the user should first correct his input.

So in the combobox.When() event first unbind the combobox, then query data and bind the combobox again.

The code to query might be in that event directly or you call some object/class for data rtetrieval, that depends on how far you push your OOP usage, it's design and the seperation of concerns (just to mention one OOP principle, that matters here).

Bye, Olaf.



 
Thanks for the well explanations I will try that.

Saif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top