Copy Record- Runtime Error (1 Viewer)

firestorm998

Registered User.
Local time
Today, 01:53
Joined
Nov 28, 2006
Messages
24
I've had a copy record button on a form for some time which functioned fine. Recently I have added the below to a combo box, which also works, but since I added it the copy record button no longer works and returns a Runtime Error -'Update of Cancelupdate without Addnew or Edit'.

I'd appreciate any suggestions,thanks.



Private Sub Event_Type_AfterUpdate()

If Me.Event_Type = "Rights Issue" Then
Me.Option_1 = "Subscribe Rights"
Else: Me.Option_1 = " "
End If
If Me.Event_Type = "Rights Issue" Then
Me.Option_2 = "Sell Rights"
Else: Me.Option_2 = "Take No Action"
End If
If Me.Event_Type = "Rights Issue" Then
Me.Option_3 = "Lapse Rights"
Else: Me.Option_3 = " If Short-Cover Short"
End If
If Me.Event_Type = "Rights Issue" Then
Me.Option_4 = "Take No Action"
Else: Me.Option_4 = " "
End If
If Me.Event_Type = "Rights Issue" Then
Me.Option_5 = "If Short-Cover Short"
Else: Me.Option_5 = " "
End If
If Me.Event_Type = "Rights Issue" Then
Me.Option_6 = "N/A"
Else: Me.Option_6 = " "
End If

End Sub
 

ajetrumpet

Banned
Local time
Today, 03:53
Joined
Jun 22, 2007
Messages
5,638
what is the code with the On_Click event of the button??
 

firestorm998

Registered User.
Local time
Today, 01:53
Joined
Nov 28, 2006
Messages
24
Then Copy Button 'On click' code is:
Private Sub copy_event_Click()
On Error GoTo Err_copy_event_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

Exit_copy_event_Click:
Exit Sub

Err_copy_event_Click:
MsgBox Err.Description
Resume Exit_copy_event_Click

End Sub


But when the error message pops up & I select debug it opens up the previous code I listed for the combo box after update event.
 

Dennisk

AWF VIP
Local time
Today, 09:53
Joined
Jul 22, 2004
Messages
1,649
Try re-writing it like this

Code:
If Me.Event_Type = "Rights Issue" Then
   Me.Option_1 = "Subscribe Rights"
   Me.Option_2 = "Sell Rights"
   Me.Option_3 = "Lapse Rights"
   Me.Option_4 = "Take No Action"
   Me.Option_5 = "If Short-Cover Short"
   Me.Option_6 = "N/A"
Else
   Me.Option_1 = " "
   Me.Option_2 = "Take No Action"
   Me.Option_3 = " If Short-Cover Short"
   Me.Option_4 = " "
   Me.Option_5 = " "
   Me.Option_6 = " "
End If
 

vbaDev

Registered User.
Local time
Today, 04:53
Joined
Feb 26, 2007
Messages
64
Could someone suggest how to do the same thing without the .DoMenuItem command, which is unreliable. DoCmd doesn't seem to have a relevant method.

Then Copy Button 'On click' code is:
Private Sub copy_event_Click()
On Error GoTo Err_copy_event_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

Exit_copy_event_Click:
Exit Sub

Err_copy_event_Click:
MsgBox Err.Description
Resume Exit_copy_event_Click

End Sub


But when the error message pops up & I select debug it opens up the previous code I listed for the combo box after update event.
 

boblarson

Smeghead
Local time
Today, 01:53
Joined
Jan 12, 2001
Messages
32,059
Could someone suggest how to do the same thing without the .DoMenuItem command, which is unreliable. DoCmd doesn't seem to have a relevant method.

It would be
DoCmd.RunCommand acCmdSelectRecord

And, if you type a space after the word RunCommand you will get the list of everything available. They should be in there.
 

Cosmos75

Registered User.
Local time
Today, 03:53
Joined
Apr 22, 2002
Messages
1,281
Last edited:

firestorm998

Registered User.
Local time
Today, 01:53
Joined
Nov 28, 2006
Messages
24
Try re-writing it like this

Code:
If Me.Event_Type = "Rights Issue" Then
   Me.Option_1 = "Subscribe Rights"
   Me.Option_2 = "Sell Rights"
   Me.Option_3 = "Lapse Rights"
   Me.Option_4 = "Take No Action"
   Me.Option_5 = "If Short-Cover Short"
   Me.Option_6 = "N/A"
Else
   Me.Option_1 = " "
   Me.Option_2 = "Take No Action"
   Me.Option_3 = " If Short-Cover Short"
   Me.Option_4 = " "
   Me.Option_5 = " "
   Me.Option_6 = " "
End If
Tried that Dennisk but getting same 'Update of Cancelupdate without Addnew or Edit' error.
 

Users who are viewing this thread

Top Bottom