go to record in DBLookUpComboBox

I need to go to a certain record in a DBLookUpComboBox...
So I have 2 tables ,
the first one is called tableone has the fields:
soc,name   (soc is primary key and it's string)

the second one named tabletwo and has the fields
date, id, no, soc (id is primary key)

Tableone is connected with a datasource to a DBLOOKUPCOMBOBOX showing the "name" field
and tabletwo (through a query) is connected to a DBGrid

When the user selects (doubleclicks) a record in the DBGrid I must show the corresponding value in the DBLookUpComboBox

How can I do that?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GhitzaAuthor Commented:
Say the following example of table contents:
soc      |    name
"soca" |  "first soc"
"socb" | "second soc"
"socc" | "third soc"
"socd" | "fourth soc"
... and so on

table two has following contents:

date             |    id  |   no   |    soc
01/01/2005  |  15   | "11"  |   "soca"
02/01/2005  |  23   | "12"  |   "socd"
03/01/2005  |  7     | "13"  |   "socb"
04/01/2005  |  29   | "14"  |   "soca"

So when the user doubleclicks on the record in tabletwo, let's say record with id=7, the DBLookUpComboBox must go to the "second soc" and display it .

I must use DBLookUpComboBox for tableone

Try this,
In the double click event of the grid, do the following,
if tableecomponentname.findkey([querycomponentname.fieldbyname('soc').asstring]) then begin
  DBLookUpComboBox.text := tableecomponentname.FieldByName('name').asstring ;
  ShowMessage('Some error message cuse it cant find it') ;
GhitzaAuthor Commented:
Dear RickJ I do not use a Table component to show the records in the DBGrid. Actually I simplified the reallity, in order to keep it simpler. So in the DBGrid I have a dynamic query. But it allways contain a field called "soc". So basically I cannot use findkey on it.
 And as for assigning a string value to the dblookupcombobox... I did not succeed so far not even with simple strings (not necesarily using your ideea)
"Cannot assign to a read-only property"

So please feel free to come with another ideea., also any of you experts... please help
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

What type of dataset is your dblookupcombo connected to?
OK, sorry I use slightly different components.
You need to use KeyValue.
So your DBLookupComboBox1.ListField would be "Name"
the DBLookupComboBox1.KeyField would be "soc"
So then in the grid doubleclick you would do this,
DBLookUpComboBox.KeyValue := query.FieldByName('soc').asstring ;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GhitzaAuthor Commented:
This is great... thanks.
It works now.
You get the points
Thanks again
Glad to help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.