Solved

DBLookupComboBox - Refresh

Posted on 1999-01-10
7
1,297 Views
Last Modified: 2008-03-17
How do I get a DBLookupComboBox to show the first record of the listsource when the Table is activated.

I've tried Table1.first but the dropdown still remains blank until I have first selected an Item.

If I have a parent table a select a record the I want the dropdown to now refresh and show the new detail records as per master table record.
0
Comment
Question by:smithsj1
[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
  • 3
  • 3
7 Comments
 

Expert Comment

by:samone
ID: 1355683
Try to set the keyvalue to a value that is significant to your setting in keyfield.
You can try to set
DBLookupComboBox.Keyvalue:="firstvalue in table"

SAM 1
0
 

Author Comment

by:smithsj1
ID: 1355684
Samone do you mean

dblookupcombobox1.keyvalue:=table1.findfield('name').asstring;

Why doesn't Inprise just default th lookup to show the first record.
0
 
LVL 1

Expert Comment

by:adeng
ID: 1355685
Open the 'listsource' table before the table that use the value from listsource.

Table1.open; <---- Table that has a listsource
Table2.open; <---- Table that use a listsource value.

if you entering the correct value in DBLookupComboBox property then everything must be ok as expected.

But if you still insist that you have to open the table that contain listsource open after the second table than you must add this code :

procedure TForm1.Table2NewRecord(DataSet: TDataSet);
begin
    Table2ID.AsInteger := 1; // i assume that the first value of table1 is 1
end;

Inprise did make Dblookupcombobox show the first record.

Adeng.
0
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!

 

Author Comment

by:smithsj1
ID: 1355686
Adeng

Samone already answered the Q to my satisfaction.
0
 

Expert Comment

by:samone
ID: 1355687
Why did you reject my answer then?
0
 

Author Comment

by:smithsj1
ID: 1355688
Samone

I needed to confirm what you meant.

"Samone do you mean "

"dblookupcombobox1.keyvalue:=table1.findfield('name').asstring; "

" Why doesn't Inprise just default th lookup to show the first record."

Submit your answer again I'll accept it now!
0
 

Accepted Solution

by:
samone earned 50 total points
ID: 1355689
Yes if you have a stringvalue as keyfield its ok.
And if you know of a string that you always got at the top you only need to set DBLookupComboBox1.KeyValue:='Firstrecord';
But I rather use a index of integers in the first field in the database.

Like if I have a TABLE 'table1' with the fields
INDEX  NAME
1      BILL
2      JOHN
3      CHARLES

I use the index field as a keyfield and name as listfield
You set the DBLCB text field like this.

DBLookupComboBox1.KeyValue:=Table1.fields[0].AsInteger;

If you don't want to create the index numbers by yourself
you can use autoincrement (if you don't use Dbase).

SAM
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

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 111
Delphi Form ownership 4 154
firemonkey Android Listview Sort items 7 101
How to add columns to a RAD Studio FMX grid at design time 1 58
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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