ReportView Search question

Started by bmclellan, April 13, 2020, 07:16:02 PM

Previous topic - Next topic

bmclellan

Hello,

I just discovered the ReportView control in dialog boxes, wow, it looks great! Wish I had have read the documentation 5 years ago :)

I presented a ReportView box today and my user asked if there was a way they could type and have it start searching through the dialog entries highlighting (one at line only) as they got closer to their search

i.e. based on the numbers below, the user would start to type 1,2,3 and the highlight bar would move down each line.
123456
123666
123677

My thoughts were to use an edit box and after each key was entered I'd go check the reportview array to find the entry, however in looking at all the search options it looks like no matter what has to be an exact match.
Since I've missed all the fun for the last 5 years, does anyone know if there is a way to do a partial search without me iterating manually through the array?

Thanks!
Barry

JTaylor

I don't think there is a built-in way to do what you want.    If your column is sorted you could use a search algorithm that should be faster, on average, than looking through every row.   A basic database index search might be something to try.  You jump half way down the array, see if the cell matches what you want or if it is is higher or lower in the list.  Depending on the answer you jump half way in the appropriate direction and check again.   If it matches the search string then move up the array until it doesn't and the previous row you checked is the first line matching the string.

Jim

stanl

Jim seemed to nail it. I would add that pre-selecting data for a report view, i.e. create a Recordset works well since an ADO Recordset has a built-in Getrows() method to convert data to an array.

bmclellan

Excellent, thanks guys, appreciate the help!

Actually, Stan, I've never tried the ADO thing.

Are you saying I can somehow export the first column of my ReportView, and do some kind of select * where (column 1 data like ("my input%") on the data and just grab the first field from it?

lol, cause if yes, can you point me in the right direction?

stanl

Not sure this is what you are after, but using ADO, I have a database with 70,000 unique ID's - So for setting up my ReportView I have a simple edit box where the user can input up to 3 chars of the ID's [ 70,000 ID's but with over a million associated rows ]


This allows a cSQL='SELECT f1,f2,f3,f4 WHERE f1 LIKE "%%':myquery:'%%";'


Then more generic code to structure any SQL for ReportView
Code (WINBATCH) Select


oRS.Open(cSQL,oConn,0,1,1)
If oRS.eof()
   oRS.Close()
   CloseConn()
   Message("Cannot Continue","SQL Query Returned No Rows")
   Goto start
Endif
MyPos=oRS.Collect("f1")
nrec=oRS.RecordCount
arrData = oRS.GetRows()
row = 0
rowflag = 1
ArrayInsert( arrData, row, rowflag, "" )
fcount=oRS.Fields.Count
flds=""
For i=0 To fcount-1
   flds=flds:oRS.Fields(i).Name:","
Next
flds=StrSub(flds,1,strlen(flds)-1)
arrB = Arrayize( flds, ',' )
For element = 0 To ArrInfo( arrB, 1 )-1
    arrData[row,element] = arrB[element]
Next


oRS.Close()


bmclellan