473,763 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

create duplicate records on a form datasheet

6 New Member
hi guys
i need some help to duplicate records on my form datasheet:
here's the example of my form results:
ClientLookup DateCaptured ForecastDate Description ForecastQuantit y Forecast Actual
UJ 18-Apr-08 01-Mar-08 Fees: Asset 1 R 31,200.00 R 31,200.00
NMBM 22-Apr-08 23-Mar-08 P-MI (E) 07/2006 3 R 47,485 R 38,849
i have 200 records deplayed in the form i'm using access2007 and i have a command button which is the built in command button to duplicate records in the form, at the moment when i click the button on one record is duplicated but i want to duplicate atleast 5 records and set the DateCaptured to today's date.

the reason why i want to user to be able to duplicate the records is that 90% of the time when the user enters the entry in the form most of the fields will remain the same and only the DateCaptured, Forecast or Actual values would need to be changed so rather than the user enters the new records he/she should be able to duplicate few rows and edit the relevant fields from there.

another thing i only sent you 7 fields of 15 fields in my form.

hope this explains clearly of what i'm trying to do.
and thanks in advance
Aug 27 '08 #1
2 4015
Aric Green
23 New Member
Why not just set the default value for the fields on your form?
Aug 27 '08 #2
missinglinq
3,532 Recognized Expert Specialist
Aric's suggestion is a good one if the record you want to copy has just been entered, i.e. if you're entering a series of records in a row.

In your form, you can use the AfterUpdate event of the control holding your data to set the DefaultValue for the field. From that time forward, until you either manually change the data or close your form, the data will be entered automatically in each new record. The syntax varies slightly, depending on the datatype of the data:

For Date fields

Private Sub YourDateControl Name_AfterUpdat e()
If Not IsNull(Me.YourD ateControlName. Value) Then
YourDateControl Name.DefaultVal ue ="#" & Me.YourDateCont rolName & "#"
End If
End Sub

For Text fields

Private Sub YourTextControl Name_AfterUpdat e()
If Not IsNull(Me.YourT extControlName. Value) Then
YourTextControl Name.DefaultVal ue = """" & Me.YourTextCont rolName.Value & """"
End If
End Sub

For Numeric fields

Private Sub YourNumericCont rolName_AfterUp date()
If Not IsNull(Me.YourN umericControlNa me.Value) Then
YourNumericCont rolName.Default Value = Me.YourNumericC ontrolName.Valu e
End If
End Sub

If, on the other hand, you want to come back at a later date and make multiple copies of a record from an earlier sessions, this should do the job:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdMultiCopy_Click()
  2. For I = 1 To 5
  3.   If Me.Dirty Then Me.Dirty = False
  4.   DoCmd.RunCommand acCmdSelectRecord
  5.   DoCmd.RunCommand acCmdCopy
  6.   DoCmd.GoToRecord , , acNewRec
  7.   DoCmd.RunCommand acCmdPaste
  8.   Me.DateCaptured = Date
  9. Next I
  10. End Sub
You could also set the Forecast and Actual fields to blank if you wanted to, just like DateCaptured is set to the current date.

You could also modify this code to accept a variable, if you wanted to.

Place an unbound textbox, call it NumberCopies.

Replace the line

For I = 1 To 5

with these lines

Expand|Select|Wrap|Line Numbers
  1. If Not IsNull(Me.NumberCopies) then
  2.   Copies = Me.NumberCopies
  3. Else
  4. Copies = 5
  5. End If
  6.  
  7. For I = 1 To Cpies
  8.  
and the user can decide how many copies to make by entering the number in the textbox. If no number is entered, a default of 5 copies will be made.

My question to you is, how do you have a command button on a form that is in Datasheet view? Unbound controls, such as command buttons, don't show on Datasheets!

Welcome to Bytes!

Linq ;0)>
Aug 27 '08 #3

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

Similar topics

2
2606
by: Terry | last post by:
I have cerated a Form, ExamsFrm, which is used to input details of exams taken at several Centres. It dosplays details from StudentTbl and has a SubForm which displays details from ExamsTble. I have incorporated some VB6 code as well as some Conditional Formatting. The code automatically updates CheckBoxes in the SubForm, depending on exam results, and the Conditional Formatting changes background colours, depending on CheckBox datum. ...
4
4154
by: Peeter Ups | last post by:
I have several tables in my database. I use these to create 'quotations' that show product code, description, selling price and quantity required. Users can enter as many lines as possible and a running $ total is updated after each line is updated. At the end of the 'quote' I simply want to press a button, clear the inputted data and restart a new 'quotation'. Any help would be appreciated. I just don't know what code to put against...
6
1542
by: Robert | last post by:
Hello, Accessors What I would like to do is create a multi-record table update. I have a table and a form for it. I want to modify it so that there is a new field (textbox) (not bound to a table field) on the form wherein the user enters a number to specify how many new records to add to the table as opposed to the 1 record which is usually inserted by Access. How do you do that? Robert
6
3076
by: 6thirty | last post by:
Hi, I've created a stocktaking database using Access XP. This is indexed by two fields - part number and shelf location. I am currently inputting all the data via a form. When I have entered a record such as: part number 202354-001 location C1-01
2
3870
by: Todd | last post by:
Hi. I want to sort the records on my form (using either a continuous form or a datasheet) by the unbound "description" column in a combo box on the form (or in the datasheet.) Here's a rough text representation of what I'm talking about FORM Item Number Description Category (text box) (text box) (combo box - 2 columns)
3
2134
by: ghat12 | last post by:
Hi, I have created a form containing 5 textfields/combo boxes and a command button to conduct searches for matching records. My results are currently displayed as a separate datasheet which is launched by specifying the query in the OnClick property of the command button. I would like to create a form that displays the results in a datasheet on the bottom portion of the same form. I understand that this requires using the form-subform...
0
2522
by: claus | last post by:
Hi, I am not a programmer but tries anyway to program a feature in a form where I am able to copy entries for the form and a subform. I have tried follow the guide here http://allenbrowne.com/ser-57.html, but my problem is that I have more than one keyfield in the join between the two tables: Hovedoplysninger and Itemoplysninger. The tree fields are: "Medarbejder", "Sagsnummer" and "Mandag". I have succeded creating the new entry...
3
2380
by: nomvula | last post by:
hi guys i need help, i have a form which is diplayed in a Datasheet view with more that 2 hundred records, when a user needs to add new entries i want him/her to select atleast 5 or more rows and click duplicate record button to duplicate those five records but at the moment only 1 record is getting duplicated
1
7274
by: xraive | last post by:
I have a problem with this. Currently I am trying Allen's code and i am not successful. Current Design Table1 (Main Form) TravelID (PK) ApprovedBY EntreredBy BudgetCode ExpenseCode
0
9386
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
10145
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
9998
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...
0
9822
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
8822
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
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
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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
2793
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.