Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combo will not display value after closed
Message
De
29/05/1999 17:19:51
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
28/05/1999 22:32:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00222776
Message ID:
00224415
Vues:
29
>Cetin:
>
>I want to let you know that my combos are working pefectly. Thank you for the help. I am no longer getting an error message that says "record out of range" and when I close and re-open the form, the data is visible and stored correctly. I couldn't ask for much more!
>
>It was a great learning experience to place the SQL statement for my Pview into the combo.init(). I will certainly implement this proceedure in the future.
>
>Cetin. Everything is working perfect, however, I want to truly understand what you helped my create. I don't just want to place the code in the correct position, have it work, and not fully understand.
>
>
>What is the true advantage of placing the SQL statement of the pview into the combo.init() and setting the variable lcSQL, versus the way I had it set up previously (which was no code in combo.init_? Previously, I placed the pview into the combo.rowsource and called the pview that way to supply the data to my combos.
>
>Why is it better to have the code placed in the .init? (at least as far as pviews are concerned)
>
>Thank you again Cetin for the instruction
>
>Jason
Jason,
Hard question :) will try best.
Pviews and SQL are really nearly same thing. There are differences of course but from point of a combo filling its items they're same. A combo doesn't need extra features of pview (let's say just view for the moment).
View and pview - in its simple form pview is a view that you can "fill in" its where parameter at run time. I'll try to keep as simple as possible so technically will not be totally correct, when you understand the (p)views totally you'll discover them by yourself :
select * from myTable where name = "Cetin" && A regular view always pulling records for "me" :)
select * from myTable where name = ?Who && Would ask you to fill in
but :
Who = "Cetin"
select * from myTable where name = ?Who && Again would pull recs for me :)

So from here to your form. Thisform.currentstate was the parameter that has a value already, like in second example here. If you set that to "" (for char) at entry your combos would be filled in because all recs would match (assuming set exact, set ansi etc at their default). But not that so easy, data environment is loaded before init, and what's the thisform.currentstate value ? Can you answer ? That was why I recommended placing SQL to combo. There combo.init could exactly read that value and fill in values we want.

Now why at combo.init with lcSQL and not directly combo property setting. lcSQL variable was created as I explained in my prev. message, you might later choose to make it a parameter so implementation would be easier.
Not written directly in PEM sheet while combo is designed, because SQL is rather long and you would face quirks of placing long SQL in PEM sheet. So doing it in init was a safe and easy way. If it was a short SQL like "select * from employee", I would say directly write it in PEM sheet and set rowsourcetype to 3.
Since this is an SQL with a "where" clause, each time this.requery called in combo when (or gotfocus), cursor is refreshed and have the values you want :)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform