Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2007

    Unanswered: Edit Record in Form with Command Button

    While in a form, I neeed to create a copy of the current record and edit that record using a command button. In particular, I need to create a copy of the current record, but have a date field increased by x number of days, where x is a value in a field of the current form - all this should be done on the click of the command button.

  2. #2
    Join Date
    Nov 2003
    Not really enough info here but what the heck....

    In the OnClick event of your Command Button:

       'Trap Errors
       On Error GoTo Error_CopyRecord
       Dim DayValue As Long
        'The variable 'DayValue' must reference the contents of
       'the Control on your Form that will hold the Value you 
       'want to add to the Date. Because of the lack of info
       'provided how this will be transforms to an integer value
       'is up to you. Perhaps it already is...I don't know.
       DayValue = Me.theControlOnForm
       'Duplicate the Current Record.
       DoCmd.RunCommand acCmdSelectRecord
       DoCmd.RunCommand acCmdCopy
       DoCmd.RunCommand acCmdPasteAppend
       'Increment the Date Field on Form by the number of Days
       'specified in the DayValue variable.
       Me.myDateFieldOnForm = DateAdd("d", DayValue, CDate(Me.myDateFieldOnForm))
       'Get Outta here...
        Exit Sub
        'Process any Errors.
        MsgBox Err.Description
        Resume Exit_CopyRecord
    Last edited by CyberLynx; 11-16-07 at 17:22.
    Self Taught In ALL Environments.....And It Shows!

Posting Permissions

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