constableparks
Registered User.
- Local time
- Today, 04:21
- Joined
- Jul 6, 2017
- Messages
- 53
User clicks a button on a form and it creates a copy of the record with a new quote number. This code works perfectly, but I want to close the original record and keep the new record on the form. How?
Code:
'This will copy the current quote into a new quote number
Dim intNewNum As Integer
On Error GoTo Err_Click
If MsgBox("Are you sure you want to create a new quote using this quote as a template?", vbYesNo, "Confirm New Quote") = vbNo Then Exit Sub
intNewNum = Nz(DMax("QuoteNum", "[TblSys]")) + 1 'Gets the new Quote Number
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste
Me.QuoteNum = intNewNum 'Assigns the new Quote Number to the copied record
DoCmd.RunCommand acCmdSave
Exit_Click:
Exit Sub
Err_Click:
MsgBox Err.Description
Resume Exit_Click