Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 02-18-2015, 05:08 PM
RubyBlue RubyBlue is offline
Junior Member
 
Join Date: Aug 2014
Posts: 9
Default DBLookupComboBox problems

Once again I am turning to the knowledgeable folk out there for help with my studies.

I want to know if the following is possible (I'm using Delphi 7):
I have two tables set up in MS Access - one for companies and one for individuals.
Now based on a selection in a radio group, where the user selects either companies or individuals, I want the DBLookupComboBox to connect to the relevant table. I've tried the following code, but when I run the code, the dropdown is greyed out

Code:
    
if (radSource.ItemIndex= 0) then
   begin
         dlcCode.ListSource:= dmo_Main.datCompany;
         dlcCode.DataField:='Code';
         dlcCode.KeyField:= 'Code;Company Name';
         dlcCode.ListField:= 'Code';
       end

   else     if (radSource.ItemIndex= 1) then
                begin
                   dlcCode.ListSource:= dmo_Main.datIndividual;
                   dlcCode.DataField:='Code';
                   dlcCode.KeyField:= 'Code;Surname';
                   dlcCode.ListField:= 'Code';
                end;
  #2  
Old 02-18-2015, 05:23 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,059
Default

Try:


Code:
dlcCode.KeyField:= 'Code';
dlcCode.ListField:= 'Code;Surname';
__________________
Regards,
Abdulaziz Jasser
  #3  
Old 02-18-2015, 05:28 PM
RubyBlue RubyBlue is offline
Junior Member
 
Join Date: Aug 2014
Posts: 9
Default

Thanks - tried it, but the dropdown is still greyed out. It enables if I select the listsource in the object inspector, but is disabled when I try to do select it within my code.

Last edited by RubyBlue; 02-18-2015 at 05:37 PM.
  #4  
Old 02-18-2015, 06:12 PM
RubyBlue RubyBlue is offline
Junior Member
 
Join Date: Aug 2014
Posts: 9
Default

Okay, so I've tried moving to code to Tform.onShow and now it's working .
Now I'm need to investigate why it didn't work in the original procedure that I had it in.
  #5  
Old 02-19-2015, 09:50 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,059
Default

Which event did you use before?
__________________
Regards,
Abdulaziz Jasser
  #6  
Old 02-19-2015, 11:36 AM
RubyBlue RubyBlue is offline
Junior Member
 
Join Date: Aug 2014
Posts: 9
Default

I used the dbtCodeChange event.
  #7  
Old 02-23-2015, 10:55 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,059
Default

Better to put the code on "OnClick" event of the TRadioGroup.
__________________
Regards,
Abdulaziz Jasser
Closed Thread

Tags
adoconnection, dblookupcombobox

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 01:13 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.