Jump to content

dblookupcombobox in dbgrid


Pier

Recommended Posts

I am sure it must be trivial, and I am aware of the demo () in which KeyField=country and ListField=country, however I do not seem to able to achieve what I want.

Let me try to explain

Table1: InvoiceNo:INTEGER(11), CustID:INTEGER(11) - Data (111,1) (222,2) (333,3) (444,1)

Table2: ID:INTEGER(11), Customer:CHARACTER(4) - Data (1,'John') (2,'Bill') (3,'Jane') (4,'Mary')

The grid should show

111   John

222   Bill

333   Jane

444    John

When we click on 'Bill' we should get a combo listing John/Bill/Jane/Mary. If we select Mary the second row in Table1 should become (222,4).

How is this achieved? How specifically should the TVCLDBColumn in the TUniDBGrid and the hidden TUniDBLookupComboBox be set?

Your help would be greatly appreciated.

Link to comment
Share on other sites

Nobody has a clue? Even a "NO, it's impossible" would help. This is a real show-stopper for the application I want to develop because essentially al the database structure is built with ids pointing to records in other tables.

Link to comment
Share on other sites

You need to specify also the datasource and datafield in the uniDbLookupcombo. They would normally be set to the same datasource as the unidbgrid. So in your case datasource should point to table1 and the datafield should be the CustID. 

(and the listsource should be set to the customer datasource. Keyfield = ID and ListField = Customer)

Link to comment
Share on other sites

Thanks alfr. This is what I tried. What I see in the table, though, is

111   1

222   2

333   3

444    1

(the dropdown is ok). Can you confirm that it should definitely work inside a dbgrid? I have been fighting with this for days... do you know of a microdemo that shows such a case working?

 

 

 

Link to comment
Share on other sites

ok, what is missing is that you also need to add a lookup field in your table1 query. This is the field that you should show in the Unidbgrid. (The CustID can be hidden)

Something like the below. So in the fields editor select "New Field". 

image.png.dcd93873d59e56a10b7f56b1244951f5.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...