Recent

Author Topic: [SOLVED] JvDBLookupDropDown combo's totally inactive????  (Read 993 times)

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 448
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
[SOLVED] JvDBLookupDropDown combo's totally inactive????
« on: March 23, 2026, 05:58:33 pm »
I've been using [Jvcl DB] JvDBLookupDropDown combo's for quite awhile for forms requiring a lookup such as Country, State, Company Type, etc.  On my Clients Mgt. form, all 3 combo's have DIED!  I've looked at other forms and can't figure out what change I made to cause this.  The complete form is active, all DBEdit's are active but State/Prov.: JvDBLukUpStates, Country: JvDBLukUpCntry and same with Category are just inactive. There is test data in these fields but these components DIED!  Anyone ever have this happen or familiar with these components from JvclLazarus [Jvcl DB]?
« Last Edit: March 24, 2026, 09:24:30 pm by 1HuntnMan »

wp

  • Hero Member
  • *****
  • Posts: 13513
Re: JvDBLookupDropDown combo's totally inactive????
« Reply #1 on: March 23, 2026, 06:17:35 pm »
Are the fields and datasets still properly connected? One unintentional keystroke may be sufficient to do this...

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 448
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: JvDBLookupDropDown combo's totally inactive????
« Reply #2 on: March 23, 2026, 08:17:14 pm »
WP, yes everything is connected. It's just one form, Contacts Mgt. My other forms are working properly, i.e. Clients, Appointments, Proposals, Sales Orders, etc.  I broke something but haven't been able to figure it out because everything seems to be connected to the tables, in this case, Clients, Proposals, States, Categories and Countries.  The last 3 tables are just what I call lookup tables for the applications forms. Those tables are maintained separately.  I'm opening them as ReadOnly because they aren't edited on any of the main forms.  Here's a snippet from FormCreate & FormShow:

Code: Pascal  [Select][+][-]
  1. From FormCreate...
  2.   {-------------------- Setup CATEGORIES Table query -------------------}
  3.   QryCat.Active:= False;
  4.   QryCat.DataBase:= ConnectCntks;
  5.   QryCat.Options:= [];
  6.   QryCat.SQL.Text:= 'SELECT * FROM CATEGORIES ORDER BY CATEGORY';
  7.   DSrcCat.DataSet:= QryCat;
  8.   QryCat.ReadOnly:= True;
  9.   {-------------------- Setup STPROVCODES Table query -------------------}
  10.   QryStates.DataBase:= ConnectCntks;
  11.   QryStates.Options:= [];
  12.   QryStates.SQL.Text:= 'SELECT * FROM STPROVCODES ORDER BY STPROVCODE';
  13.   DSrcStates.DataSet:= QryStates;
  14.   QryStates.ReadOnly:= True;
  15.   {--------------------- Setup COUNTRIES Table query --------------------}
  16.   QryCntries.DataBase:= ConnectCntks;
  17.   QryCntries.Options:= [];
  18.   QryCntries.SQL.Text:= 'SELECT * FROM COUNTRIES ORDER BY CODE';
  19.   DSrcCntries.DataSet:= QryCntries;
  20.   QryCntries.ReadOnly:= True;
  21.  
  22. from FormShow...
  23. QryCntks.Open;
  24. QryStates.Open;
  25. QryCntries.Open;
  26. QryCat.Open:
  27.  

dseligo

  • Hero Member
  • *****
  • Posts: 1683
Re: JvDBLookupDropDown combo's totally inactive????
« Reply #3 on: March 24, 2026, 12:17:07 am »
Check if you get results after opening queries:

Code: Pascal  [Select][+][-]
  1. QryCntks.Open;
  2. QryStates.Open;
  3. QryCntries.Open;
  4. QryCat.Open: // <--- you have colon here instead of semicolon
  5.  
  6. ShowMessage(
  7.     QryStates.FieldByName('STPROVCODE').AsString + LineEnding +
  8.     QryCntries.FieldByName('CODE').AsString + LineEnding +
  9.     QryCat.FieldByName('CATEGORY').AsString);

If you don't get data from ShowMessage, there is something wrong with your query, tables, database, ...
If you get expected result (first row), then put new DBGrid component and DataSource on the form (just for test). Select Dataset in DataSource component and DataSource in DBGrid (using Object inspector). Don't change anything else.
If you see data in DBGrid, then you messed something with DataSource or DBGrid.
If you don't see data in DBGrid, then put that 'ShowMessage' in some button OnClick event and check if you see that first line when clicking that button. If you don't, maybe somewhere in your code you accidentally close your queries.

P.S.: Now I see you write about JvDBLookupDropDown component. I don't use that component, but it should be similar to test it. I still recommend that you test with DBGrid, as I described. That way you will be sure you have the data you expect.

P.S.: Now I also noticed that you set your queries to be read only. Comment this just to test it. Table that is changed with JvDBLookupDropDown component shouldn't be read only.
« Last Edit: March 24, 2026, 12:22:15 am by dseligo »

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 448
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: JvDBLookupDropDown combo's totally inactive????
« Reply #4 on: March 24, 2026, 12:59:20 pm »
Great idea!  I'll do that and check the results.  Be back later, thanks!

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 448
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: JvDBLookupDropDown combo's totally inactive????
« Reply #5 on: March 24, 2026, 01:31:12 pm »
Okay, just after opening the Contacts Mgt. Form Queries, I commented out making the 3 lookup tables, Categories, States, Countries as ReadOnly. I expected it shouldn't make a difference but good for this test. See the attachment, it's displaying the first record in each table: State=AB(Alberta), Country=AT(Austria) and Categories=Retailer. So, up to just after the tables are opened, everything good. So, I'll just keep going thru the code.  Next test is not use JvDBLookupCombo and use the Lazarus provided DBLookUp but don't expect it to make a difference.
Code: Pascal  [Select][+][-]
  1. procedure TFrmCntksMain.FormShow(Sender: TObject);
  2. begin
  3.   //=> Check the transaction...
  4.   if not TransCntks.Active then
  5.     TransCntks.StartTransaction;
  6.   //=> Check the Connections...
  7.   if not ConnectCntks.Connected then
  8.     begin
  9.       ConnectCntks.Connected:= True;
  10.       ConnectCntks.ExecuteDirect('PRAGMA busy_timeout=5000;');
  11.       ConnectCntks.ExecuteDirect('PRAGMA foreign_keys=ON;');
  12.       ConnectCntks.ExecuteDirect('PRAGMA journal_mode=WAL;');
  13.       ConnectCntks.ExecuteDirect('PRAGMA synchronous=NORMAL;');
  14.     end;
  15.   //=> Bootstrap...
  16.   QryCntks.Open;
  17.   QryCat.Open;
  18.   QryStates.Open;
  19.   QryCntries.Open;
  20.  
  21.   //=> Test lookup connections...
  22.   ShowMessage(
  23.     QryStates.FieldByName('STPROVCODE').AsString + LineEnding +
  24.     QryCntries.FieldByName('CODE').AsString + LineEnding +
  25.     QryCat.FieldByName('CATEGORY').AsString);
  26.  
  27.   //=> Wire next line to Sense edit/insert for Save/Cancel buttons off/on...
  28.   WireSaveCancelStateChange(Self, DSrcCntks);
  29.   if not QryCntks.IsEmpty then
  30.     UpdateTTLCntks
  31.   else
  32.     QryCntks.Append;
  33.   DBEditFName.SetFocus;
  34. end;
  35.  

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 448
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: JvDBLookupDropDown combo's totally inactive????
« Reply #6 on: March 24, 2026, 09:24:05 pm »
Figure it out, I had the States and Countries JvDBLookupCombo's set correctly except the one for the Category.  I had the LookupField set to the primary Auto-Inc field CATID but displaying Category field.  Lookup field set to the CATID can't populate the Category field in Contacts Table with the Category field from the Categories table. The CatID is an auto-Inc field, type Integer.  I changed it to Lookup the Category field from the Categories table, both string fields, that fixed it but I don't know why that would affect the States and Countries JvDBLookUpCombo's.  But, all is well. Thanks anyway dseligo esp. good idea to do a ShowMessage just after opening the tables to verify the Query was opening properly...

 

TinyPortal © 2005-2018