?
Solved

select dbedit text depening on edit text

Posted on 2007-03-28
11
Medium Priority
?
856 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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

762 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