0

The application I'm writing has a main form where all the database fields and DBGrid that contains the entire SQLite dataset (ExpItemQuery) reside. I have designed a database search functionality into the application using a separate Delphi form. The search form can find records based on a number of fields (project ID, dates, vendor, etc.). The search results are shown in a DBGrid using a different dataset query (SearchQuery) of the same main database records as the main form.

The problem I struggling with is how once the user selects the correct record from the Search Form can I bring it back to the main form, select the correct record to display on the main form. To make matters a bit more challenging, each of these datasets will have the same content (fields) from the database, but the record count and numbers will be completely different, so using them to locate the proper record won't work. I have looked into using the CopyRecord method of TFDQuery however, there is little to no documentation or examples to follow so I'm not sure its appropriate. I have also looked at similar methods GotoCurrent and CloneCurosr which I don't believe will work properly given the differences in the main form dataset and the subset dataset.

The only potential solution I can reasonably come up with is to copy the SearchQuery record information as selected by the user into a memory storage record, close the search form, search the main form dataset for the correct record using several key fields and display it.

I'm hoping that someone has a better solution to this problem that I've may have overlooked.

3
  • not ver clear to me, so on your mainform you have a dbgrid that is populated, and you have another form to search for a row in the same table ? Why not just search on the mainform itself then ? Commented Sep 24 at 10:00
  • When you Search , you should get back some unique ID as well from the Database. Regardless of fields .... Then you send this ID back to the MainForm . Do a qryData.Locate('ID',47362,[]) Commented Sep 24 at 10:38
  • @user1937012 That is what I'm looking for and makes sense. Thanks. Commented Sep 24 at 14:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.