Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Listbox for records not in range
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00034169
Message ID:
00034172
Views:
33
>I have a grid full of children. Originally, these children were not a separate table. There was a single field in the parent table which would hold something amorphous like "188.1 - 188.8, 203, 205" which would appear like that on the reports. This field would contain a single number, a range of numbers, or a range + some individual numbers. Each individual number is now a child record (ten of them in the above example). However, I need a way to show, both on the form and on reports, the range and the individual records. I have decided to have two textboxes for the range start and end, and a listbox for the records not in the range. In the above example, txtbox1.value = 188.1, txtbox2.value = 188.8, and lstbox would have 203 and 205. When displaying a record in the form, txtbox1 and txtbox2 are bound to fields startrange and endrange in the parent record, and lstbox will show all children of that parent record WHERE NOT BETWEEN(childfield, startrange, endrange)
>
>Finally, here's my question: what is the fastest, most efficient way to keep that listbox full when navigating records? I'm going to use the listbox differently when adding records. I can put the above expression in the lstbox.Refresh inside a IF NOT THISFORM.Editmode ... ENDIF. I'm just afraid that if I don't do this just right, I'll get something really sluggish. For example, should I SELECT ... INTO CURSOR and make the cursor the rowsource? Or should I make the .RowSourceType = 3 - SQL Statement? When THISFORM.Editmode = .T. and I'm adding or editing, lstbox will hold a cursor full of selected child numbers to be saved as child records when I click the Save button. Its rowsource will be changed around when that happens.
>
>Thanks for your patience, all.

Personally, I prefer cursors. Just remember to use CREATE CURSOR first (e.g. in Listbox.Init), then you populate cursor (in the same event) skipping child records and INSERT INTO cursor. When you add/remove items to listbox it will involve INSERT INTO or DELETE from cursor, and when you finally save you firstly delete all child records and then insert new ones using the cursor. It will not be sluggish at all (just couple records to DELETE/INSERT).
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform