473,385 Members | 1,647 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,385 software developers and data experts.

Copy and pasting within a form

18
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 6395
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,556 Expert Mod 16PB
The former would be the recommended way. The wizard-created code is rubbish :(
Oct 11 '08 #3
lrw0831
18
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,556 Expert Mod 16PB
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 Expert Mod 2GB
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,556 Expert Mod 16PB
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
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...
4
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...
17
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...
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...
1
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...
0
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). ...
1
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...
5
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...
8
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.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.