Solved

go to record in DBLookUpComboBox

Posted on 2007-04-01
7
850 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
  • 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 250 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now