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

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

select dbedit text depening on edit text

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
Vrtnar
Asked:
Vrtnar
  • 5
  • 4
1 Solution
 
EddieShipmanCommented:
reformat your query to something like this:

Query1.SQL.Text := 'SELECT FIELD2 FROM TABLE WHERE FIELD1 = ' + QuotedStr(Edit1.Text);
0
 
VrtnarAuthor Commented:
But how do I display FIELD2 in my dbedit ??
0
 
EddieShipmanCommented:
set the dbEdit's datafield to field2.
0
Independent Software Vendors: 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!

 
VrtnarAuthor Commented:
and if i have a couple of dbedits to change that way,what would be rigt?
0
 
EddieShipmanCommented:
You set the DataField property tothe field in the dataset that you want to show in the DBEdit.
0
 
VrtnarAuthor Commented:
edits are not the same...
0
 
EddieShipmanCommented:
I don't understand what you mean or what you want to do, here.
0
 
VrtnarAuthor Commented:
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
 
EddieShipmanCommented:
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
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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