Solved

select dbedit text depening on edit text

Posted on 2007-03-28
11
826 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
  • 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
 

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

12 Experts available now in Live!

Get 1:1 Help Now