[SOLVED] Error: Identifier not found????? lazarus / 16-Databases ---------------------------------------------------------------------- 1HuntnMan · 2025-11-20 14:33 Looking for advice, maybe someone can see the problem but I can't! I have a small procedure that counts the number of records just as a feedback to the user.  I have this no problem in my Appointments unit but in my ClientsMgt unit, I'm getting this error in the Subject on this topic.  If you can see the issue, please let me know. In the interface I declare the Query: QryCountClnts: TSQLQuery. Then I declare the procedure UpdateTTLClients in private.  The procedure: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFrmClientsMgt.UpdateTTLClients;begin  SafeClose(QryCountClnts);  //=> Ensure a clean state...  QryCountClnts.SQL.Text:= 'SELECT COUNT(*) AS TTL FROM CLIENTS';  QryCountClnts.Open;  try    EditTTLClients.ReadOnly:= False;    EditTTLClients.Text:= QryCountClnts.FieldByName('TTL').AsString;  finally    EditTTLClients.ReadOnly:= True;    QryCountClnts.Close;  end;end;  Then, on the form I have a TEdit called EditTTLClients as per the procedure above.  So, in FormShow I update the TEdit and also when a record is added or deleted I update the TEdit in procedures TFrmClientsMgt.QryClientsAfterDelete and also AfterPost, i.e. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFrmClientsMgt.QryClientsAfterDelete(DataSet: TDataSet);begin  UpdateTTLClients;end; procedure TFrmClientsMgt.QryClientsAfterPost(DataSet: TDataSet);var  CurID : Integer;begin  UpdateTTLClients;  //-> Move to the saved record...  CurID:= DataSet.FieldByName('CUSTNO').AsInteger;  PMSDataModule.QryClients.Locate('CUSTNO',CurID,[]);end;  When I compile I get these error for every occurrence of QryCountClnts which is just the Query define in Form Create: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  //-> Define the properties for the QryCountClnts Query...  QryCountClnts.DataBase:= PMSDataModule.ConnectPMSDB;  QryCountClnts.Transaction:= PMSDataModule.TransPMSDB;  QryCountClnts.SQL.Text:= 'SELECT COUNT(*) AS TTL FROM CLIENTS';  Can't figure this one out, any advice I will probably kick myself, probably very obvious... ---------------------------------------------------------------------- marcov · 2025-11-20 14:38 QueryCOUNTClnts vs QryClients ? ---------------------------------------------------------------------- 1HuntnMan · 2025-11-20 16:58 QryClients is on the DataModule. This QueryCOUNTClnts is on the form, local.  It's separate and only used AfterPost/AfterDelete.  The problem is declaring it, which this is exactly the way I have this setup in the Appointments unit/form and it works.  This is a Identifier not found: QryCountClnts.  It's got to be the way I'm declaring it, in the interface. ---------------------------------------------------------------------- rvk · 2025-11-21 09:24 Quote from: 1HuntnMan on November 20, 2025, 05:58:53 pmQryClients is on the DataModule. This QueryCOUNTClnts is on the form, local.  It's separate and only used AfterPost/AfterDelete.  The problem is declaring it, which this is exactly the way I have this setup in the Appointments unit/form and it works.  This is a Identifier not found: QryCountClnts.  It's got to be the way I'm declaring it, in the interface. Then at least show how you declared it (where). You say the QueryCOUNTClnts is on the form... then you don't add this yourself? So it's just in TFrmClientsMgt. So you should be able to use QryCountClnts in all class functions and procedures of TFrmClientsMgt. ---------------------------------------------------------------------- 1HuntnMan · 2025-11-30 20:11 rvk, I rather rebuilt the form and if I don't add this particular Query, it runs fine.  I added quite awhile back just for info. for the user, i.e. how many contacts, clients or appointments. The Connection and Transaction components are on the DataModule.  I did some changing and did have everything queries, datasources, the connection/trans on the datamodule.  I'm revamping the whole app and currently have just the mainform, datamodule and one app. form - Appointments.  The only query components I have on the datamodule is the Connection, Trans and the queries/datasources for lookup tables, i.e. States, Countries, etc.  DropDownCombo's on the forms, i.e. Appointments. Only 2 drop- downs, using JvDBLookUp component because I can drop-down more than one lookup field, State Abbrev. and the State Fullname. On the one form Appointments, have 3 queries with their datasources: Appts., Client and Contacts tables/queries.  Redesigned the form and compiled and had a few errors from typos but then only error which doesn't make sense is this same query for displaying in a TEdit the number of appointments.  See attached.  Also, it's just a Query component, no datasource, here's the code/procedure with where it's declared first as Private and then a snipped in the Form Create and then the Update Procedure which is used AfterDelete and AfterPost to show in a TEdit: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   private  Searchfield : String;    Keys        : TStringList;    procedure QryAppmtsAfterDelete(DataSet: TDataSet);    procedure QryAppmtsAfterPost(DataSet: TDataSet);    procedure UpdateTTLAppmts; procedure TFrmAppmnts.FormCreate(Sender: TObject);begin  Keys:= TStringList.Create;  //=> Add Items to the CmboBxIndex...  CmboBxIndex.Items.Clear;  CmboBxIndex.Items.Add('Client/Customer');  CmboBxIndex.Items.Add('Contacts (L,F,M');  CmboBxIndex.Items.Add('Appt. Date');  CmboBxIndex.Items.Add('Appt. No.');  //=> Define the properties for the QryCountAppmts query...  QryCountAppmts.DataBase:= PMSDataModule.ConnectPMSDB_RO;  QryCountAppmts.Transaction:= PMSDataModule.TransRO;  QryCountAppmts.SQL.Text:= 'SELECT COUNT(*) AS TTL FROM APPOINTMENTS'; procedure TFrmAppmnts.UpdateTTLAppmts;begin  QryCountAppmts.SQL.Text:= 'SELECT COUNT(*) AS TTL FROM APPOINTMENTS';  QryCountAppmts.Open;  try    EditTTLAppts.ReadOnly:= False;    EditTTLAppts.Text:= QryCountAppmts.FieldByName('TTL').AsString;  finally    EditTTLAppts.ReadOnly:= True;    QryCountAppmts.Close;    EditTTLAppts.Refresh;  end;end; procedure TFrmAppmnts.QryAppmtsAfterDelete(DataSet: TDataSet);begin  UpdateTTLAppmts;end; procedure TFrmAppmnts.QryAppmtsAfterPost(DataSet: TDataSet);var  CurID : Integer;begin  UpdateTTLAppmts;  //=> Move to the saved record...  CurID:= DataSet.FieldByName('APPTID').AsInteger;  QryAppmts.Locate('APPTID',CurID,[]);  DBChkBxActive.Refresh; //=> Check to verify DBChkBxActive refreshes...end;  The error is occuring at the line above in FormCreate, not during compile, compile has no errors, it's happening only at runtime the instant the form is created in the FormCreate at the line above or here it is: QryCountAppmts.DataBase:= PMSDataModule.ConnectPMSDB_RO; Error attached... ---------------------------------------------------------------------- rvk · 2025-11-30 20:30 Quote from: 1HuntnMan on November 30, 2025, 09:11:55 pmThe error is occuring at the line above in FormCreate, not during compile, compile has no errors, it's happening only at runtime the instant the form is created in the FormCreate at the line above or here it is: QryCountAppmts.DataBase:= PMSDataModule.ConnectPMSDB_RO; Error attached... That just looks like your form is created before your data module. Check the order in which your forms/modules are created. Your data module should be the first one (because you depend on it during the form create). If the order is correct, then when and how is PMSDataModule.ConnectPMSDB_RO created? But my guess PMSDataModule is not yet created (which works result in access violation). ---------------------------------------------------------------------- 1HuntnMan · 2025-12-01 17:03 Yup, forgot to check the lpr unit. I hand coded it in with the DataModule created first before the Main unit and then created the datamodule, mainform, and the Appointments form. Compiled and cleaned up and when I created the datamodule Lazarus put the Create statement for the datamodule into the lpr unit again and it was declared twice.  That fixed it, thanks for advising about the create order in the LPR. Take care...