Solved

select dbedit text depening on edit text

Posted on 2007-03-28
11
843 Views
Last Modified: 2008-03-18
I have linked dbedit to a datasource and a field.
How can I have dbedit showing text from the database depending on edit text?
example:
In the database I have
field1   field2      
(field1 has same text as edit)
(field2 is linked to dbedit)
So after my table opens if edit text = field1.text then dbedit.text = field2
However I do not want to replace edit with dbedit
0
Comment
Question by:Vrtnar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
11 Comments
 
LVL 26

Expert Comment

by:EddieShipman
ID: 18808113
reformat your query to something like this:

Query1.SQL.Text := 'SELECT FIELD2 FROM TABLE WHERE FIELD1 = ' + QuotedStr(Edit1.Text);
0
 

Author Comment

by:Vrtnar
ID: 18808649
But how do I display FIELD2 in my dbedit ??
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 18809607
set the dbEdit's datafield to field2.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Vrtnar
ID: 18813901
and if i have a couple of dbedits to change that way,what would be rigt?
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 18815146
You set the DataField property tothe field in the dataset that you want to show in the DBEdit.
0
 

Author Comment

by:Vrtnar
ID: 18822333
edits are not the same...
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 18822565
I don't understand what you mean or what you want to do, here.
0
 

Author Comment

by:Vrtnar
ID: 18822839
I have 10 edits that contain various text.
I have a table that contains the same texts from each edit and a percentage value for each entry.
Easy way would be to use dbedits to represent the table but instead i must use plain edit.
So next to edits I placed dbeditst to get the percentage.
So how can I filter them according to edittext

0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 50 total points
ID: 18823655
Can you show an example, I still don't understand why you need TEdit's
Are you saying that you have a table defined something like this:

Field1  - contains the values from the TEdits
Field2 - contains the percentages, will be the TDBEdits

You can't have a separate DBEdit for each of those values without
having 10 datasets. the dataset will point to ONE ROW in your table
and the DBEdit's will point to the Field2 in THAT ROW.

You can select all the percentages from the table into a dataset and
then loop through and populate TEdits like this:
  Table1.Open;
  Table1.First;
  while not Table1.EOF do
  begin
    if Table1.FieldByName('Field1').AsString = Edit1.Text then
      Edit11.Text := Table1.FieldByName('Field1').AsString;
    if Table2.FieldByName('Field1').AsString = Edit2.Text then
      Edit12.Text := Table1.FieldByName('Field1').AsString;
    if Table3.FieldByName('Field1').AsString = Edit3.Text then
      Edit13.Text := Table1.FieldByName('Field1').AsString;
    if Table4.FieldByName('Field1').AsString = Edit4.Text then
      Edit14.Text := Table1.FieldByName('Field1').AsString;
    if Table5.FieldByName('Field1').AsString = Edit5.Text then
      Edit15.Text := Table1.FieldByName('Field1').AsString;
    if Table6.FieldByName('Field1').AsString = Edit6.Text then
      Edit16.Text := Table1.FieldByName('Field1').AsString;
    if Table7.FieldByName('Field1').AsString = Edit7.Text then
      Edit17.Text := Table1.FieldByName('Field1').AsString;
    if Table8.FieldByName('Field1').AsString = Edit8.Text then
      Edit18.Text := Table1.FieldByName('Field1').AsString;
    if Table9.FieldByName('Field1').AsString = Edit9.Text then
      Edit19.Text := Table1.FieldByName('Field1').AsString;
    if Table10.FieldByName('Field1').AsString = Edit10.Text then
      Edit20.Text := Table1.FieldByName('Field1').AsString;
  end;
  Table1.Close;

In the code above, you have a Table that points to your dataset containing the data.
Then you have 10 TEdits that contain your selections, and 10 TEdits that contain your
percentages.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21156492
Forced accept.

Computer101
EE Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

695 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