Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Last inserted record not found

Status
Not open for further replies.

PinnacleDan

Programmer
Jun 10, 2004
9
0
0
US
I am new to this forum and hope I am in the right category.
I have a program that clears an Access table then, in a loop, inserts several records into it.
Code:
SQL="Insert Into Materials (JobCode, Item)"
    SQL=SQL & "Values ('" & CurJob & "','" & CurItem & "')" 
    DB2.Execute SQL, dbFailOnError

I then load the table into a datagrid for review.
Code:
SQL = "Select * From Materials "
    frmRpt2.AdodcR1.RecordSource = SQL
    frmRpt2.AdodcR1.Refresh
    frmRpt2.DataGrid1.Refresh

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 think you'll have better luck in the Access VBA forum.
 
I tried that once and found it was the wrong forum. My code is in a VB-6 program not in Access VBA.
 
Oh, ok, I see. Yes, you're using an ADO Data Control, which is a pretty squirrely item that is generally not recommended for use in production. You might consider creating an ADO recordset and binding it to your datagrid rather than binding the data control. If this isn't an option for you, you might consider resetting the datasource property of the datagrid each time you redo the recordset of the data control.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top