B
Bob
Hello,
I'm in the process of writing a maintenace program. It is a single table application. Simplist of all!!! BUT..... When I go to copy a record and
change the primary key, it always comes back and says it couldn't perform the operation because it would create a duplicate.
Help me out on this one please. Here's my code:
Private Sub btnCopy_Click())
Dim Response
Response = MsgBox("Are you sure you want to COPY this record?", vbYesNo, "Copy Confirmation")
If Response = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSave
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdPaste
MIRCtl.Value = 99999
MIRCtl.SetFocus
MIRDateInit.Value = Now
MIRCloseDate.Value = MIRDateInit.Value
AddedIndicator.Caption = "Copy"
AddedIndicator.Visible = True
End If
End Sub
-------------------------------------------------------------------------------------------------------
MIRCtl is the primary key. I want to change the copied key to '99999' actually before pasting the record so it doesn't create a dupe then insure the
user changes it before he saves it, if he doesn't, I'll delete the record with the '99999' key.
I've seen some light examples but those had a PK assigned by Access. It seems so easy, but I can't get the sequence of commands proper and I'm
probably missing some.
Could someone straighten me out on this??????
Bob
I'm in the process of writing a maintenace program. It is a single table application. Simplist of all!!! BUT..... When I go to copy a record and
change the primary key, it always comes back and says it couldn't perform the operation because it would create a duplicate.
Help me out on this one please. Here's my code:
Private Sub btnCopy_Click())
Dim Response
Response = MsgBox("Are you sure you want to COPY this record?", vbYesNo, "Copy Confirmation")
If Response = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSave
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdPaste
MIRCtl.Value = 99999
MIRCtl.SetFocus
MIRDateInit.Value = Now
MIRCloseDate.Value = MIRDateInit.Value
AddedIndicator.Caption = "Copy"
AddedIndicator.Visible = True
End If
End Sub
-------------------------------------------------------------------------------------------------------
MIRCtl is the primary key. I want to change the copied key to '99999' actually before pasting the record so it doesn't create a dupe then insure the
user changes it before he saves it, if he doesn't, I'll delete the record with the '99999' key.
I've seen some light examples but those had a PK assigned by Access. It seems so easy, but I can't get the sequence of commands proper and I'm
probably missing some.
Could someone straighten me out on this??????
Bob