PinnacleDan
Programmer
I hope I am in the right forum.
I have a VB program that first clears an Access table. Then, using a recordset opened to another database, inserts several records into it.
I then load the table into a datagrid for review.
The problem is that the last record inserted does not display in the grid. I added a 1-second delay after the insert and the problem seems resolved. However, I am sure this is not the right way to ensure the insert is complete before I read the table. Any help would be appreciated.
I have a VB program that first clears an Access table. Then, using a recordset opened to another database, inserts several records into it.
Code:
Set WK = CreateWorkspace("", "admin", "", dbUseJet)
Set DB2 = WK.OpenDatabase(MasterFile)
SQL = "Delete * From Materials "
DB2.Execute SQL, dbFailOnError
Do While Not RSmatl.EOF
SQL="Insert Into Materials (JobCode, Item)"
SQL=SQL & "Values ('" & CurJob & "','" & CurItem & "')"
DB2.Execute SQL, dbFailOnError
RSmatl1.MoveNext
Loop
Code:
SQL = "Select * From Materials "
<===delay inserted here===
frmRpt2.AdodcR1.RecordSource = SQL
frmRpt2.AdodcR1.Refresh
frmRpt2.DataGrid1.Refresh