• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 361
  • Last Modified:

Duplicating a record in a form, errors out if attempted after a save or after moving from a previous record

MS Access database - built using '97, converted to 2000 file format, working in 2003

A record is created and saved.  At a later date/time the user goes in and updates the record.  They click the "Update Record" button.  This set the field for active to 0, creates a new record, then copies the current record into a new record, sets some data, then sets the record in edit mode.

If the form is opened and the update record button is clicked, all goes according to plan.  If the form is opened, and the user goes to a different record, it errors out.  If the record is saved and then an update record is attempted, it error out.
The error received:
The command or action 'PasteAppend" isn't available now

The updated record code:
Private Sub cmdUpdateRecord_Click()
On Error GoTo Err_cmdUpdateRecord_Click

    Me.Active = False

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
    Me.Species_Qty = Me.Total_Species_Qty
    Me.Mod_Date = Now()
    Me.Mod_Species_Qty = 0
    Me.Active = True
    Exit Sub

    MsgBox Err.description
    Resume Exit_cmdUpdateRecord_Click
End Sub

1 Solution
Just a quick thought - if I was copying a record, I'd prob just run a SELECT INSERT sql query on the table to copy the last record. Then you just need to go to the latest record in the form.

Of course this might not apply but hope it helps :o)

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now