button created by wizard causes error (xp)

mitchem1

Registered User.
Local time
Yesterday, 20:05
Joined
Feb 21, 2002
Messages
153
I used the wizard to insert a button used to create a duplicate record. The button worked fine under NT but since we've converted to XP, it causes an error. All I get is a message that says 'The record that Access was unable to paste has been inserted into a table called Paste Errors'. I tried removing the button and reinserting it (under XP) but still get the error. Any ideas would be greatly appreciated.
 
What's the code on the button?
 
I compared the code under both NT and XP and it was identical:

Private Sub cmdDuplicate2_Click()
On Error GoTo Err_cmdDuplicate2_Click


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

Exit_cmdDuplicate2_Click:
Exit Sub

Err_cmdDuplicate2_Click:
MsgBox Err.Description
Resume Exit_cmdDuplicate2_Click

End Sub
 
The code from the wizards is obsolete; Microsoft just haven't upgraded the wizards. :mad:

I can't remember what the sequence is for duplicating a record but now, Access uses the DoCmd.RunCommand acCmd syntax over the DoCmd.DoMenuItem method.

The three lines in your code should be:

Code:
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdCopy
    DoCmd.RunCommand acCmdPasteAppend
 
Unfortunately that code generates the same error.
 
Is there any fields Indexed to have No Duplicates in this table? Just a suggestion
 
That doesn't seem to be the problem. However, I think I have narrowed it a bit. I compared the record that I was attempting to duplicate with the record that was pasted into the 'Paste Errors' table. All fields pasted successfully except 3. They were all Date/Time fields. Unfortunately, the field properties were identical in both tables, so I'm still at a loss.
 

Users who are viewing this thread

Back
Top Bottom