by stecenko » Wed May 01, 2013 1:10 am
Here are some ways of doing this.
assuming: numref is character and you have a filter on the view
casos.numRef=?getNumRef
The following will populate the cursor only with the required records.
dimension dlaFilters[1,2]
store 'getNumRef' to dlaFilters[1,1]
store this.value to dlaFilters[1,2]
thisform.oVpmDataHandler.requeryView('casos_view', @dlaFilters)
If you have for some other reason, you have to populate casos_view with all the records and then want to find just one record, then
thisform.oVpmDataHandler.requeryView('casos_view') && populates with all records
select casos_view
if locate for numRef=This.Value and not empty(this.value)
* do what you need for this record
endif
If you will have more than one record for numref, then
thisform.oVpmDataHandler.requeryView('casos_view') && populates with all records
select casos_view
if locate for numRef=This.Value and not empty(this.value)
scan while numRef=this.Value
* do what you need for these records
endscan
endif
The seek only works if you have an index created after the view is populated. I'm assuming that the view has order by numref. So often it will be faster to read through the view until you find the first record with numref=this.value, than it is to build the entire index on all records before you can test to see if you even have a record to process.
Reading through the entire view to locate a particular numRef will take less time than building an index.
When you do a locate you are reading every record until you either find one that you want or reach the end of the view. When you build an index you are reading every record and writing it to an index; then you can seek to see if one of them is what you want.
I hope this helps. I'm not sure how big casos_view is or what you're going to do with it. But, this should give you some idea on how to figure out what to do.
Richard Stecenko
Interactive Computer Services Inc.
Victoria, British Columbia
204.453.2052