Delphi dbedit

Posted on 2007-07-29
Last Modified: 2013-11-23
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

Question by:elschott
    1 Comment
    LVL 21

    Accepted Solution

     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.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
    Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now