Since you're using TADOTable
, I suspect your table is configured to operate asynchronously.
This can be done via property ExecuteOptions: TExecuteOptions;
Of course, if you set ExecuteOptions := [];
, your data should load synchronously, but with the unpleasant side-effect of blocking your UI.
The 'friendlier' option would be to hook the OnFetchComplete event which is decalred as follows: procedure (DataSet: TCustomADODataSet; const Error: Error; var EventStatus: TEventStatus) of object;
The exact specifics requires more information on what exactly you're trying to achieve. You could:
- Call your report method directly from the
OnFetchComplete
handler. - Use your handler to enable a menu option / button / action that is disabled while the data is loading.
- Use a synchronisation object (such as
TSimpleEvent
) and signal the event inside theOnFetchComplete
handler. Then other code can simply call theWaitFor
method blocking code until the event has been signalled.