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

create duplicate records on a form datasheet

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 ForecastQuantity 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 3982
Why not just set the default value for the fields on your form?
Aug 27 '08 #2
missinglinq
3,532 Expert 2GB
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 YourDateControlName_AfterUpdate()
If Not IsNull(Me.YourDateControlName.Value) Then
YourDateControlName.DefaultValue ="#" & Me.YourDateControlName & "#"
End If
End Sub

For Text fields

Private Sub YourTextControlName_AfterUpdate()
If Not IsNull(Me.YourTextControlName.Value) Then
YourTextControlName.DefaultValue = """" & Me.YourTextControlName.Value & """"
End If
End Sub

For Numeric fields

Private Sub YourNumericControlName_AfterUpdate()
If Not IsNull(Me.YourNumericControlName.Value) Then
YourNumericControlName.DefaultValue = Me.YourNumericControlName.Value
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
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...
4
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...
6
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...
6
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...
2
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...
3
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...
0
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...
3
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...
1
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.