473,757 Members | 7,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DoCmd.DoMenuIte m copy and paste

121 New Member
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 11152
nico5038
3,080 Recognized Expert Specialist
I must warn you for using the "DoCmd.DoMenuIt em" 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, 560 views)
Aug 31 '08 #2
phill86
121 New Member
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 Recognized Expert Specialist
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.RunComman d 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 New Member
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.RunComman d 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 Recognized Expert Specialist
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
3129
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 closed and explicitly saving the contents. Only problem is that each time the DoCmd executes, I lose my insertion point. Net effect is that after the first keystroke, the user's typing just clobbers the first chararacter in the field...
6
8463
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 by VisitDt" I'm getting this error message: Errno is 2465. Err.description is "Can't find field '|' referred to in your expression"
4
3443
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 second does not produce an error. The "Save" button uses "Docmd.Save" to save the record. If I insert "Me.Dirty = False" before "Docmd.Save" an error is produced. Why doesn't "Docmd.Save" produce an error but instead silently fails to save the...
2
5197
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 DoCmd.DoMenuItem acFormBar, 7, 6, 0, acMenuVer70 But this doesn't:
4
21626
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 via the file menu events using the clipboard. However, what I don't get is how is the program able to produce a context menu in the textbox area. When right clicking, the context pops up and allows to cut/copy/paste/delete, etc.. But the thing is, I...
7
11638
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 is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an OpenFileDialog: Dim result As DialogResult = Pic_Sel.ShowDialog() If (result = DialogResult.OK) Then
17
5129
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 about 20 textboxes on the form). Also to ensure that the button can't get used if the cursor isn't in a textbox field. And to ensure the contents of the clipboard are "text" contents that have been cut/copied from one of the textboxes on the form. ...
3
2008
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 cancel an ADD operation (new empty record already created for the bound form) and then make changes to the RecordSource for my form. So, I want to wait for the DoCmd.DoMenuItem to complete. How do I do it? Being somewhat of a newbie, I only know how...
4
6676
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 entry fields and so there is a button you press which then takes to through to a print preview of the invoice and you print out the invoice but recent ly this message ahs started appearing and does not allow you to view the print preview of the invoice...
0
9489
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9298
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10072
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.