Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

go to record in DBLookUpComboBox

Posted on 2007-04-01
7
Medium Priority
?
883 Views
Last Modified: 2008-01-09
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?
0
Comment
Question by:Ghitza
[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
  • 4
  • 3
7 Comments
 
LVL 3

Author Comment

by:Ghitza
ID: 18832175
Say the following example of table contents:
tableone:
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

Thanks
0
 
LVL 8

Expert Comment

by:RickJ
ID: 18833918
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 ;
end
else
  ShowMessage('Some error message cuse it cant find it') ;
0
 
LVL 3

Author Comment

by:Ghitza
ID: 18834592
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
0
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.

 
LVL 8

Expert Comment

by:RickJ
ID: 18834603
What type of dataset is your dblookupcombo connected to?
0
 
LVL 8

Accepted Solution

by:
RickJ earned 1000 total points
ID: 18834668
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 ;
0
 
LVL 3

Author Comment

by:Ghitza
ID: 18834742
This is great... thanks.
It works now.
You get the points
Thanks again
0
 
LVL 8

Expert Comment

by:RickJ
ID: 18834763
Thanks.
Glad to help.
0

Featured Post

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

688 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