• Duplicate record with different key fields (Access 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Duplicate record with different key fields (Access 2000)

    Author
    Topic
    #401302

    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

    Viewing 1 reply thread
    Author
    Replies
    • #789461

      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 =

      • #789519

        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

      • #789520

        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

    • #789462

      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 =

    Viewing 1 reply thread
    Reply To: Duplicate record with different key fields (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: