I have a main form, from which I open a another form, frmSchedule
frmSchedule has a datagrid, which is bound to an ado data control
The data control is based on a table called TempSchedule. Before I open frmSchedule, I delete the contents of TempSchedule and replace with a fresh schedule.
However, gridSchedule will be blank. Now if I use a message box after frmSchedule opens, gridSchedule will be filled after I click ok.
I tried datSchedule.Refresh but that did nothing either. At the moment my code is
VB Code:
  1. stSQL = "DELETE * FROM TempSchedule"
  2. cnnAsset.Execute stSQL
  3. stSQL = "INSERT INTO TempSchedule SELECT Schedule.* From Schedule " & _
  4.     "WHERE Schedule.Sch_AssetCode = '" & stAssetCode & "'"
  5. cnnAsset.Execute stSQL, lAffected
  6.    
  7. frmSchedule.lTotalSchedules = lAffected

Then in the frmSchedule Load event
VB Code:
  1. ' Now wait until the schedule data loads
  2. While lCountSchedules < lTotalSchedules        
  3.         lCountSchedules = Me.datSchedule.Recordset.RecordCount
  4.         Me.datSchedule.Refresh
  5. Wend

Surely theres a better way!?