PinnacleDan
Programmer
I was transfered to this forum and hope I am in the right category.
I have a VB program that clears an Access table then, in a loop, 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?
I have a VB program that clears an Access table then, in a loop, 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 "
frmRpt2.AdodcR1.RecordSource = SQL
frmRpt2.AdodcR1.Refresh
frmRpt2.DataGrid1.Refresh