473,804 Members | 3,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy and pasting within a form

18 New Member
I have the main form where employees enter "issues". Some issues have fields that are the same. My fields are

Issue ID (auto)
Product
Entered BY
Issue Type
Priority
Request from
Status
Assigned to
Model
Description

Is there a way to have a "Copy" button that would copy all of the information in the form, and then paste it into the same form but in a new record?

Example...Say I have an issue that needs to be assigned to 2 different departments, I want to enter a new issue (we'll just say its issue 9) then have a copy button that would copy all of that information then open issue 10 and paste it in there.

Thank you for any help in advanced.

Lindsay
Oct 10 '08 #1
6 6532
bluemoon9
56 New Member
Hi,
create a command button (cmdCopy) on the form and paste this code onto the "On Click" event
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdSelectRecord
  2.   DoCmd.RunCommand acCmdCopy
  3.   DoCmd.GoToRecord , , acNewRec
  4.   DoCmd.RunCommand acCmdPaste
Or you can use the access wizzard to create a "Duplicate Record" command. Here is the code from the wizzard:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdCopy_Click()
  2. On Error GoTo Err_cmdCopy_Click
  3.     DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
  4.     DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
  5.     DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
  6.  
  7. Exit_cmdCopy_Click:
  8.     Exit Sub
  9.  
  10. Err_cmdCopy_Click:
  11.     MsgBox Err.Description
  12.     Resume Exit_cmdCopy_Click
  13.  
  14. End Sub
hopes this'll help.
bluemoon
Oct 10 '08 #2
NeoPa
32,579 Recognized Expert Moderator MVP
The former would be the recommended way. The wizard-created code is rubbish :(
Oct 11 '08 #3
lrw0831
18 New Member
How would i code it so that it only copies a few of the fields, not all of them?

SUpposed I just want Product, Entered BY, Issue Type, Priority, Request from, and Status to be copied and pasted onto the next issue.
Oct 13 '08 #4
NeoPa
32,579 Recognized Expert Moderator MVP
That would be an entirely different issue.

You would need to save your own copies of the data required, move to the rnext record, then update the relevant controls with the saved data.
Oct 13 '08 #5
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. I suggest you consider something different which may help with your requirement to 'copy' values from one record to the next - don't copy them, set the default value for the controls concerned instead.

How is this done? In the After Update event of each control whose value you want to carry forward simply enter the following event code, substituting the correct name of the control in each case:

Expand|Select|Wrap|Line Numbers
  1. Me![your control name].DefaultValue = "'" & Me![your control name] & "'"
This will set the default value for the control concerned to whatever was last entered. The default value property is a string (regardless of the type of the underlying field), hence the use of single quotes on either side of the value of the control.

I use this technique a lot when I want to carry forward field values from record to record. It's a lot easier and safer to set defaults than it is to copy values from one record to another. Using defaults there is then no question of accidentally creating new records at the wrong time, which is what will happen if you copy values into a blank record on a button press, say.

-Stewart
Oct 13 '08 #6
NeoPa
32,579 Recognized Expert Moderator MVP
That's a good point Stewart. I fully endorse that.
Oct 13 '08 #7

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

Similar topics

7
11646
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
4
6081
by: mrmagoo | last post by:
If I create a form and add add a bunch of controls and code, etc to it, I can see that Visual Studio adds all of the requisite "creation" code behind the form. If I wanted to create a 2nd copy of the exact form, how would I go about that? Could I just copy the code from the first form, including the Windows-generated code, and paste it in the code-behind of the 2nd form? I see that there is a warning not to modify the code-behind using...
17
5487
by: emma.sax | last post by:
Hi all, I have a form where we would like the user to input their email address twice, to ensure they've typed it correctly, as is found on most sign-ups I'm looking for a solution to the problem where a user (and me it has to be said) just either highlights the email address with their mouse (or Ctrl-A) and then Ctrl-C, Ctrl-P (or right-click copy, right-click paste) into the next field down.
17
5139
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. ...
1
3796
by: Grant Smith | last post by:
I've got an application that I can copy some text out of the RichTextBox control. I would like to keep the formatting so I'm able to copy it to the Clipboard with RTF formatting. I have no trouble pasting the formatted text into wordpad (which supports RTF formatting) but it won't paste into notepad (no RTF support). I know that if I copy something in wordpad with RTF formatting and then paste it into notepad the text will paste. What...
0
1428
by: gcardozo | last post by:
Could anyone help me with the task of copying and pasting the values of changing cell references in excel using code for a macro?(macro to copy and paste values within a currently selected column). I have this code for performing the similar task but for a certain specified range....I need help on how I can setup code for a macro to copy and paste values within a selected column, based on which column is selected. THANKYOU! Sub Macro1() '...
1
1822
by: SeeSharp Bint | last post by:
I have a form with a datagrid containing 3 columns linked to an in memory dataset. Only the 3rd column is editable. Beneath that I have a rich text box bound to the same data as the 3rd column and this is also editable. The user can enter text in the column or rich text box. If I press CTRL C in this datagrid column, followed by CTRL V to copy the string to another record, I get a pile of junk pasted prior to the string i copied eg The...
5
11159
by: phill86 | last post by:
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...
8
15445
by: jh | last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a textbox but can't figure out how to accomplish this for a listbox. Any help? Thanks.
0
9707
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
10586
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
10338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
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...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
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...
1
4301
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
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.