×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

duplicating entries on a form

duplicating entries on a form

duplicating entries on a form

(OP)
I am building a form to enter data on railcars.  If I have to enter data on 100 cars, it gets tedious.  What I want to be able to do is enter the data once, and have it copy "x" number of times to the table.

In addition, each entry needs to have a unique identifier which will be entered as well.  It would be great if I could enter a range of values for this field, and have the rest of the data replicate.  Does anyone have a solution?

Thanks in advance.

RE: duplicating entries on a form

Sounds like you might be adding cars into inventory. Each of the cars have general information that is the same, and you want the easy way out!

You could create a form that allows you to enter all the info that will be repeated. A field to enter the number of new entries to make in the car table. And a button to start the process. Am I on the right track? (pun)

John

John A. Gilman
gms@uslink.net

RE: duplicating entries on a form

(OP)
Yes sir, that is exactly what I am looking to do!  On a form, enter all the data that will be duplicated as well as have a field that takes a range of car numbers (car #'s 200-215, 360-363, 401, 500-599, etc..).  Then a button that will populate a table with the listed car numbers and the duplicated data.

RE: duplicating entries on a form

Just to make sure we are understanding each other regarding the range of numbers. Lets say you are entering some new cars, and the starting car number is NOT generated by the computer, you could enter the starting number into a field called StartNumber and then enter the ending number into a field called EndNumber. Then the code could just start creating new records using the info from the form starting with the start number, increment the number + 1 for each record until the ending number is reached.

If this is what you want to do just let me know, or post more detail regarding the process.

John

John A. Gilman
gms@uslink.net

RE: duplicating entries on a form

(OP)
That is correct.  I would be great if I could enter multiple ranges all at once (not all of the cars will be in a consecutive range, see previous reply), however that may be out of my scope.  The numbers are not generated by the computer, however there is an autonumber in the table for new entries.  I don't suppose that will affect the data entry.  What do you suggest?

RE: duplicating entries on a form

I would work with one set of new entries at a time. Enter the numbers like the make belive section above and wait until the code finishes with that batch.

You will need to create an unbound form with all the fields for the user to fill in, including the startNumber and endNumber then the following code will be called from a button click event.

Private Sub cmdAddNewCars_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim newNumber As Integer
newNumber = Me.startNumber
Set db = CurrentDb()
Set rs = db.OpenRecordset("Your Table Name Here")
With rs
    Do While newNumber <= Val(Me.endNumber)
        .AddNew
        !Your_Car_Number = newNumber
        'add your other fields here
        .Update
        newNumber = newNumber + 1
    Loop
End With

End Sub

John A. Gilman
gms@uslink.net

RE: duplicating entries on a form

(OP)
John, first off, thanks for the help.  I have a couple of questions regarding the above code.  While I have done some work in VB, I still have a long ways to go, eitherhoo...

First, when I type in...

Dim db As DAO.Database

DAO does not show up in the drop box as an option.  I can choose AccessObject, ACDataObjectType or DataAccessPage (amoung a number of different options).  FYI I am working in Access2000.  What do I need to do?  Do I need to substitute one of the above options?

Does "!Your_Car_Number" represent the car# field in the table?  And if so, would the code be written as such

Table!tblName.fieldName = newNumber   etc..

Do I need to write any code before ".AddNew" or ".Update"?

Sorry to hassle you with all these questions.  I really do appreciate the help.  This is an important project I'm on and unfortunately I have no one in the office to reference.  Thanks again.

RE: duplicating entries on a form

You need to set a reference to the DAO Code library. when you are in a code window click tools, references, then find the following library - Talk Microsoft DAO 3.5 Object Library

John A. Gilman
gms@uslink.net

RE: duplicating entries on a form

Ignore the "Talk" in the last posting. :) dont know where it came from

John A. Gilman
gms@uslink.net

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close