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.
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
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
RE: duplicating entries on a form
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
RE: duplicating entries on a form
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
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
John A. Gilman
gms@uslink.net
RE: duplicating entries on a form
John A. Gilman
gms@uslink.net