Setting Query 'Current Row' with Result Data From 2nd 'Search' Query lazarus / 16-Databases ---------------------------------------------------------------------- mrmikehicks · 2009-08-31 16:09 I have Lazarus and Firebird working great on both MAC (OS X) and PC (Vista Home Virus.) I have a fb database with number of tables. This is only about one table. All the zeoslib components are setup and working correctly. I start with some dbmemo and dbedit fields on the form and fill them with the main query (select * from table.) A dbnavigator clicks thru the query and all is working fine. I also have on the form, a search button, that calls a lookup dbgrid form that takes in the search argument and uses a 2nd 'search' query to select the rows returned by the select. Still all working fine. Next, I select a single row from the search query (selected by mouse click on the dbgrid row) and grab all the data in the row (all 4 table fields) and put it in a global record variable. Then I hide the lookup form (can't close it yet until the calling form gets the data.) Thanks for reading this far. Now, to the problem. I want to use the returned data from the search dbgrid to position the row or cursor in the original query. This would have the affect of selecting the 'found' row and filling all the data aware components (dbmemos, dbedits etc) with the searched for record. From that point the user can still continue to use the dbnavigator to go forward or backward in the query. I don't know how to set the row in the original query. Do I have to loop thru the whole query and compare each field against my 'found' data to see if that is the correct position, and then just exit the loop, leaving the query positioned at that spot??? I've searched 32 pages of this forum and on the web for days without finding an answer. Please help. ---------------------------------------------------------------------- Marc · 2009-08-31 18:22 dataset.locate btw, if you ise IDs as an unique key for your rows, you only have to lookup this id (and not seachting for a set of maybe unique values) ---------------------------------------------------------------------- mrmikehicks · 2009-08-31 19:56 Thanks Marc, after a bit more reading about the locate method, I came up with a solution that puts the original query where it should be:     if not (dmr.zquery_item.Locate('ID', item_id_str, [])) then begin       dmr.zquery_item.SQL.Clear;       dmr.zquery_item.SQL.Add('Seletc * from item');       dmr.zquery_item.Open;     end;     dmr.zquery_item.Refresh; You were correct, in that the ID (primary key) field was the only field I needed to search for, so for this part of the application, I didn't use the data in the other 3 fields. Thanks again, a little nudge in the right direction does wonders. ---------------------------------------------------------------------- mrmikehicks · 2009-08-31 20:01 On second thought, not sure if I need to run the 'select * from item' again if the primary key is not found. Not sure where that would leave the pointer after a failed locate method. And anyway, if I can't locate the primary key, things would be really more screwed up than I realize.