Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Warwick, Warwickshire, England
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Duplicate record with different key fields (Access 2000)

    I've worked out that i can use the following lines to create a duplicate record:

    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdCopy
    DoCmd.RunCommand acCmdPasteAppend

    but my table requires a unique number in the ProductID field. How do i change the contents of the record before the pasteappend?

    Each record in my table has a unique product code. I want to be able to copy the record details, change the product code to something different and then add it to the table.
    Anyone give any pointers?
    John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Duplicate record with different key fields (Access 2000)

    The easiest way out would be to use an AutoNumber field - it will automatically generate a unique number.

    Otherwise, try changing the ProductID value after the Paste/Append but before doing anything that saves the record:

    RunCommand acCmdSelectRecord
    RunCommand acCmdCopy
    RunCommand acCmdPasteAppend
    Me.ProductID = <calculate new value here>

  3. #3
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Warwick, Warwickshire, England
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicate record with different key fields (Access 2000)

    Excellent!!
    I didn't realise that I could amend the data in this way - I had presumed that the pasteappend would have already saved (or attempted to save) the record.
    I'd started working through a long routine to copy the field values to variables, create a blank, then paste the variable back in ......tooooo long
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •