Error when duplicating records

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • samdev

    #1

    Error when duplicating records

    I have used the wizard to create a Duplicate Record command button on a
    form. It works fine for a single duplicate but if I want to duplicate
    an additional record I receive an error:

    "The command or action 'Paste Append' is not available right now."

    I have to close out of the form and reopen to get the button to work
    again. A bit of a nuisance.

    Any suggestions.

    Below is the code the wizard has written - much thx for any
    suggestions...

    Private Sub Duplicate_Click ()
    On Error GoTo Err_Duplicate_C lick


    DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuIte m acFormBar, acEditMenu, 2, , acMenuVer70
    DoCmd.DoMenuIte m acFormBar, acEditMenu, 5, , acMenuVer70 'Paste
    Append

    Exit_Duplicate_ Click:
    Exit Sub

    Err_Duplicate_C lick:
    MsgBox Err.Description
    Resume Exit_Duplicate_ Click

    End Sub

  • Marshall Barton

    #2
    Re: Error when duplicating records

    samdev wrote:
    >I have used the wizard to create a Duplicate Record command button on a
    >form. It works fine for a single duplicate but if I want to duplicate
    >an additional record I receive an error:
    >
    >"The command or action 'Paste Append' is not available right now."
    >
    >I have to close out of the form and reopen to get the button to work
    >again. A bit of a nuisance.
    >
    >Any suggestions.
    >
    >Below is the code the wizard has written - much thx for any
    >suggestions. ..
    >
    >Private Sub Duplicate_Click ()
    >On Error GoTo Err_Duplicate_C lick
    >
    >
    DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuIte m acFormBar, acEditMenu, 2, , acMenuVer70
    DoCmd.DoMenuIte m acFormBar, acEditMenu, 5, , acMenuVer70 'Paste
    >Append

    Are you sure the record was saved before trying to add
    another? If you're not sure, add:
    If Me.Dirty Then Me.Dirty = False
    to the top of the procedure.

    Note that using that wizard generated code tries to copy
    every **visible** control, even ones you should not copy
    (e.g. the primary key). That also means that it does not
    copy any invisible values.

    For much more control over the dup operation, use this kind
    of logic:

    With Me.RecordsetClo ne
    .AddNew
    !thisfield = Me.thisfield
    !thatfield = Me.thatfield
    !otherfield = Me.otherfield
    !datecreatedfie ld = Now
    ' skip autonumber field or use
    ' !pkfield = somevalue
    .Update
    Me.Bookmark = .LastModified
    End With

    --
    Marsh

    Comment

    Working...