[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2878
  • Last Modified:

Delphi dbedit

I have a form whereby I want to enable a search feature. I have two edit boxes one to search by surname and one to search by employee number. The remainder of the fields on the form are dbedits which look at a database and display the appropriate results.

Is there a way to have the dbedits start off empty and allow a user to enter the search criteria or will I have to use regular edit fields. I have tried disabling the Datasource i.e.

Datasource.enabled := false

this seems to work but an error noise is made when the form is displayed suggesting something is wrong. Maybe a solution is to link the fields to the database after the form has been displayed but this seems like a lot of code for what I want to do which is start with the fields empty. When the search results are returned the dbedit fields should be returned with the data from the query.

Secondly when the datasource is disabled I cannot enter any search criteria in a dbedit field is this possible or do I need to change this to an edit field not linked to the database??

Hope this makes sense

0
elschott
Asked:
elschott
1 Solution
 
developmentguruCommented:
 Ok, they should definitely be TEdit instead of TDBEdit.  Once you find your results just populate the two edits.  Depending on your situation you can use a Dataset.Locate to find the record instead of a query.  

  One other suggestion... Instead of having edits that show the results, use a DBGrid.  There can be multiple partial matches for a search.  Seeing them all can help the user refine, or end, their search (by selecting a visible record).  In the caseof using a grid for the results you can use a filter or a query.

  Let me know if you need more.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now