Paste append issues

shift2076

Registered User.
Local time
Today, 12:57
Joined
Feb 5, 2007
Messages
51
Hi all,

I have a form for entering time off for work. Each day of vacation has its own record in a table because we need to track who's covering that shift, and it could be different each day. The form for entering requests has a button which is supposed to copy that record and create a new one and open it in the form, so you can easily add multiple days without having to enter all of the information over again. However, if I enter vacation for July 1, July 2, and July 3, when I go into the table, I only see a request for the last day I entered.

Now... because the way my controls are set up (some auto-populate based on other controls) there are three different forms - one for new requests, one for modifying requests, and one specifically for adding more days to a request.

This button I'm having problems with works on the new and mod forms, but does not work on the add date form.

Here is the code that performs the paste append:
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70
DoCmd.OpenForm "PopupAddDate"
And the form controls on the add date form are -
Allow Edits - No
Allow Additions - Yes

If anyone can point me in the right direction, I would be grateful.

Thank you,
MJ
 
I also took the above code and replaced it with:
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste

In this attempt I received the message:
Run-time error '2046'
The command or action 'Paste' isn't available now.

Still trying,
MJ
 
Got it. Finally!

There were certain fields that I had locked and disabled. Apparently access didn't like this. I don't know which did it, the locking or not being enabled. Frankly, I DON'T CARE. It works. :)

Hope me rambling to myself here helps someone!
MJ
 
Oh... here's a copy of the final coding, if anyone is having a problem along similar lines:

If Me.Dirty Then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70
DoCmd.Close
DoCmd.OpenForm "VacationAddDate", acNormal, , , acFormEdit
DoCmd.RunCommand acCmdRecordsGoToLast
Else
If MsgBox("There were no changes made to this request.", vbOKOnly, "Cannot Continue") = vbOK Then
End If
End If

As you can see, I went back to the original copy/paste that access uses as default for the 'duplicate record' button. But this checks to see if there were changes made to the record first so there's no exact duplicate records.
 

Users who are viewing this thread

Back
Top Bottom