• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1394
  • Last Modified:

DBLookupComboBox - Refresh

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
smithsj1
Asked:
smithsj1
  • 3
  • 3
1 Solution
 
samoneCommented:
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
 
smithsj1Author Commented:
Samone do you mean

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

Why doesn't Inprise just default th lookup to show the first record.
0
 
adengCommented:
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
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!

 
smithsj1Author Commented:
Adeng

Samone already answered the Q to my satisfaction.
0
 
samoneCommented:
Why did you reject my answer then?
0
 
smithsj1Author Commented:
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
 
samoneCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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