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:
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...