473,388 Members | 1,230 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

DoCmd.DoMenuItem copy and paste

121 100+
Hi I have a main form that holds records for scheduled meetings, date time location etc... in that form i have a sub form that has a list of equipment resources that you can assign to the meeting in the main form. I have two buttons in the sub form one for selecting and copying all the records and another for pasting the records this enables me to copy and paste the equipment resources from one scheduled meeting to another.

The buttons are coded as follows

Select and copy:-


Expand|Select|Wrap|Line Numbers
  1. DoCmd.DoMenuItem acFormBar, acEditMenu, acSelectAllRecords, , acMenuVer70
Expand|Select|Wrap|Line Numbers
  1. DoCmd.DoMenuItem acFormBar, acEditMenu, acCopy, , acMenuVer70

Paste:


Expand|Select|Wrap|Line Numbers
  1.     DoCmd.GoToRecord , , acNewRec
Expand|Select|Wrap|Line Numbers
  1. DoCmd.DoMenuItem acFormBar, acEditMenu, acSelectRecord, , acMenuVer70
Expand|Select|Wrap|Line Numbers
  1. DoCmd.DoMenuItem acFormBar, acEditMenu, acPaste, , acMenuVer70

This all works fine if i follow these steps.
1: open form
2:locate meeting 1
3:copy equipment from meeting 1
4: locate meeting 2
5:paste equipment from meeting1 to meeting 2


it will not work if i edit meeting 2 first ie. if i take the following steps
1:open form
2:locate meeting 2
3:delete equipment record from list
4:locate meeting 1
5:copy equipment from meeting1
6:locate meeting 2
7:paste equipment from meeting1 to meeting 2


when the records have been pasted using the first example the MS Access message box "you are about to paste 2 records ok cancel" appears

when the second example is used the MS Access message box "you are about to paste 2 records ok cancel" does not appear
and if you look at the table behind the forms it has not updated even though it looks like the new records have been added in the form.

if i do not use the buttons and do the tasks "manualy" either using the copy and paste icons on the toolbar or use the edit copy and paste menu

or if i use short cut keys ctrl c and ctrl v

it works fine which is why i think that it may be related to the butons.

This is the sql statement in the subform

Expand|Select|Wrap|Line Numbers
  1. SELECT T_EquipBookTemp.EquipBookTmpID, T_EquipBookTemp.EquipID, T_EquipBookTemp.StartTimeID, T_EquipBookTemp.EndTimeID, T_EquipBookTemp.SessionID, T_EquipBookTemp.EquipBooked, T_ActiveSession.StartDate, T_ActiveSession.EndDate, T_ActiveSession.StartTime, T_ActiveSession.EndTime, T_EquipBookTemp.box09, T_EquipBookTemp.EquipBooked
i also have cascade update and cascade delete applied in the relationship between the two tables

Please help

Regards Phill
Aug 31 '08 #1
5 11062
nico5038
3,080 Expert 2GB
I must warn you for using the "DoCmd.DoMenuItem" command.
When the user does click on the form of another application the execution will fail... :-(

For the general "move" problem I created in the past a sample database to show how to move items in a list and in a subform. Both "Up/Down" to create a user defined sequence and "Left/Right" for filling a selection like Access does in several wizards with [<] and [>} buttons.

Just checkout the attached sample.

Nic;o)
Attached Files
File Type: zip Sample-Listbox-Datasheet-Up-Down-LeftRight2000.zip (57.0 KB, 556 views)
Aug 31 '08 #2
phill86
121 100+
hi nico,

thanks for the reply i dont understand why it works fine if i do not edit the record first or if i edit the record then close and reopen the form and then paste it also works fine it seems to be that it is not updating the underlying table for some reason is there any way to reload the form before i paste the records?

Cheers Phill
Aug 31 '08 #3
nico5038
3,080 Expert 2GB
Hi Phill,

The data on the form will be in a "pre update" status. When moving to another record the BeforeUpdate event will be triggered and then the data will be saved in the database.
You can "force" this save of the record by issuing a save command like:
DoCmd.RunCommand acCmdSaveRecord

As you see this is no "DoMenuItem" command and all "DoMenuItem" commands can best be "translated" into "RunCommand" statements.

Nic;o)
Aug 31 '08 #4
phill86
121 100+
Hi nico,

thanx for the reply that still did not work i have changed all the code on the buttons to runcommands and for some reason the records do not get pasted in the table if the records have been edited previously the second time you try and paste the records you do not get the ms access mesaage box that says "you are about to paste 2 records ok cancel" so this points to something that is happening in the table or query if you paste it manually ie ctrl v or via the edit menu it works please help

thanks phill

Hi Phill,

The data on the form will be in a "pre update" status. When moving to another record the BeforeUpdate event will be triggered and then the data will be saved in the database.
You can "force" this save of the record by issuing a save command like:
DoCmd.RunCommand acCmdSaveRecord

As you see this is no "DoMenuItem" command and all "DoMenuItem" commands can best be "translated" into "RunCommand" statements.

Nic;o)
Sep 1 '08 #5
nico5038
3,080 Expert 2GB
I think your delete combined with the cascading links is causing this "trouble"

So I guess we need a new approach to handle the move.Obviously you want to move single and multiple records from one "main" to another "main" table.
This can be achieved in multiple ways. For my left/right move I use a Yes/No field for the selection and that's also an option for you.
The other approach would be to handle the matter from a multi select listbox, although the coding will be harder in this manner.

To start it might be a good thing you attach a sample .mdb to your next comment (write your reply and after saving follow the "edit" link at the bottom to manage an attachment).

Nic;o)
Sep 1 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: (Pete Cresswell) | last post by:
I've got this DoCmd in a fields Change() event so that as the user types, the underlying table (also visible in another screen...) will be updated in realtime - instead of waiting for the screen TB...
6
by: Squirrel | last post by:
I have a command button on a subform to delete a record. The only statement in the subroutine is: DoCmd.RunCommand acCmdDeleteRecord The subform's recordsource is "select * from tblVisit order...
4
by: WJA | last post by:
I'm probably missing something here but I can't understand the following. When 2 users try to save a record with the same primary key (a number field), the first record saves as expected, but the...
2
by: deko | last post by:
I'm trying to expand a popup form and make additional controls available by making the form footer visible and resizing the form. This works: Me.FormFooter.Visible = Me!tglAdvanced.Value...
4
by: Legendary Pansy | last post by:
I was checking out the 101 C# Samples, specifically Windows Forms - Use the Clipboard. I took a look at the code for a while, and I understand what the program is doing with the cut, copy, pasting...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
17
by: Steve | last post by:
I'm trying to code cut, copy, and paste in vb 2005 so that when the user clicks on a toolbar button, the cut/copy/paste will work with whatever textbox the cursor is current located in (I have...
3
by: cm5th | last post by:
I understand Access lets the VBA statements following a DoCmd statement execute before a DoCmd has completed. I have a situation where I use a DoCmd.DoMenuItem (copied from the UNDO button VBA) to...
4
by: gazza10001 | last post by:
Hi i hope you can help my company uses access and has modified for its needs usually what happens is you serach for the invoice by its number and then it brings all the information up such as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.