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

using command button to copy record in a form

i am inputting records using a form. how do i put a command button on the form that will copy the record i just input----sometimes i have the same record that needs to be put in 3 or 4 times and i would rather just be able to click a button and copy it.
Feb 9 '07 #1
5 28122
Rabbit
12,516 Expert Mod 8TB
Use the On Click event to run a DoCmd.RunSQL Append.
Feb 9 '07 #2
NeoPa
32,556 Expert Mod 16PB
I would put code in your Form_BeforeUpdate procedure, that sets the Defaults for the fields to be duplicated, to the new values. This way you will only save them as a duplicate (or more likely a partial duplicate) when the operator has chosen to add the new record. Defaults will not effect updates of existing records.
Feb 10 '07 #3
rajq
1
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdDuplicate_Click()
  2. On Error GoTo Err_cmdDuplicate_Click
  3.  
  4.  
  5.     DoCmd.RunCommand acCmdSelectRecord
  6.     DoCmd.RunCommand acCmdCopy
  7.     DoCmd.RunCommand acCmdRecordsGoToNew
  8.     DoCmd.RunCommand acCmdSelectRecord
  9.     DoCmd.RunCommand acCmdPaste
  10.  
  11. Exit_cmdDuplicate_Click:
  12.     Exit Sub
  13.  
  14. Err_cmdDuplicate_Click:
  15.     MsgBox Err.Description
  16.     Resume Exit_cmdDuplicate_Click
  17.  
  18. End Sub
Feb 8 '08 #4
NeoPa
32,556 Expert Mod 16PB
Rajq's code is pretty well what you want - but be careful if you have any unique indexes in your record. In that case it will fail.
If you don't have any in your table then this should be perfect.
Feb 8 '08 #5
NeoPa
32,556 Expert Mod 16PB
A (possibly) related thread (Copy Record Structure (Related Records)).
Feb 27 '08 #6

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

Similar topics

6
by: MLH | last post by:
I've followed the instructions found on Microsoft's site... http://support.microsoft.com/default.aspx?scid=kb;en-us;149119&Product=acc97 Here are those instructions... To play and record...
9
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
3
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality...
4
by: John Smith | last post by:
I have a continuous form. there is a command button with the following code for the OnClick event: DoCmd.OpenForm "frmPlants", , , "PlantsID =" & Me!PlantsID I click the button and frmPlants...
14
by: keri | last post by:
Hi, Simple version of the question..... How do I use the where clause of the open form command to show an account with a matching ID to be displayed when the form is opened? Eg. I select a...
1
by: CoolFactor | last post by:
MY CODE IS NEAR THE BOTTOM I want to export this Access query into Excel using a command button on an Access form in the following way I describe below. Below you will find the simple query I am...
15
by: BaneMajik | last post by:
I am working with an Access 2003 inventory database. When a piece of equipment goes bad we junk it and delete it from the database. We have been copying the record to an excel form for storage just...
11
by: OldBirdman | last post by:
I have a form with several bound textboxes. These are routinely updated by User. The table in RecordSource for this form currently has 8 fields not shown on this form, but which occasionally need...
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:
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
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
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...
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
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...
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,...

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.