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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delayed Table 1

Status
Not open for further replies.

fileman1

Technical User
Feb 7, 2013
152
GB
I have some code on a form which generates a new record. However after adding one or two records there seems to be differences between the Primary key number of the bound table (seen on a bound text box) to what I get on my PK1 value.
Although there are differences, when I use a list box to find a record, or look in the table, there seems to be no problems. It's just a bit alarming seeing differences. I have tried Me.Requery statements but it remains the same.?

Code:
Dim rst As Recordset
Dim db As DAO.Database
    Set db = CurrentDb()
    Dim rst As Recordset
    Set rs1 = db.OpenRecordset("MAIN", dbOpenDynaset)
    
        rs1.AddNew
        rs1!IncidentNumber = Me.INCN
        PK1 = rs1!ID1
        rs1.Update
       
    Me.PK=PK1

    Set rst = Me.RecordsetClone
    rst.FindFirst "ID1 =" & PK1
    If rst.NoMatch = False Then
        Me.Bookmark = rst.Bookmark
    Else
        MsgBox "not found"
    End If
 
Have you tried setting a breakpoint in your code and stepping through while looking at the values? You might need to swap the PK1 = rs1.ID1 with the rs1.Update.

Duane
Hook'D on Access
MS Access MVP
 
Many thanks Duane. The PK1 was in the correct position. I had stepped through it previously, however if I had gone one more line I would have found it. After the above code I had Me.Requery, and that after entering the first record with further records made the table resort to the first record. So now all fine, and thanks for your help, I had stepped through code so many times and missed it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top