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

Adding a new record to a table

Status
Not open for further replies.

robojeff

Technical User
Dec 5, 2008
220
US



I am attempting to add a new record to a table and I am able to access the table OK and move to the last record with .MoveLast

But then I add a new record with .AddNew and the record appears in the table but when I attempt to edit that record, I find that I am not indexing the new record but the last record so I added another .MoveLast but this does not select the new record for me to update.

how do I add a new record to the end of the table and then select the new record to update it?

thank you

Code:
Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbAppendOnly)

     If rst.EOF = False Or rst.BOF = False Then
        rst.MoveLast
        rst.AddNew
        rst.MoveLast
        With rst
            .Edit
            !Assembly = Me.Asm
            .Update
        End With
        rst.close    ' Close the recordset.
   
        Set rst = Nothing
        Set dbs = Nothing
    End If
 

Problem solved...

I changed the following:

Code:
   If rst.EOF = False Or rst.BOF = False Then
        rst.MoveLast

        With rst
           .AddNew
           .Update
           .MoveLast
        
           .Edit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top