Add multiple new records?

P

ptlm65

I am trying to add many new records at once.

What I need is to enter about 25 invoice numbers at once and thos
invoice numbers are linked to one employee. Is this possible? Pleas
help. Thank you
 
K

Klatuu

I am assuming you have an employee table and a related invoice table. If you
don't, you should. Then you need a form with a subform. The form should be
a single record form with the employee table or a query on that table as the
record source. The subform should be based on the invoice table or a query
 
P

ptlm65

Thanks I will create a subform based on the invoice table. Is i
possible for a user to enter several invoice #'s at once withou
entering one at a time? For instance entering invoice # 22 thru 45
without having to manually enter one at a time, linked to employee Mr
Smith.
I am assuming you have an employee table and a related invoice table.
If you
don't, you should. Then you need a form with a subform. The for
should be
a single record form with the employee table or a query on that tabl
as the
record source. The subform should be based on the invoice table or
query
 
K

Klatuu

Yes, it is possible, but would take some coding to accomplish it. The code
would be in the form, not the sub form. You could provide two text boxes -
one for the from number and one from the to number. The a command button to
add the records. It might go something like this (untested air code):

Dim lngFrom as Long
Dim lngTo as Long
Dim lngCounter as Long
Dim dbf as Database
Dim rst as Recordset

Set dbf = CurrentDb
Set rst = CurrentDb.OpenRecordset("InvoiceTable", dbOpenDynaset)
lngFrom = Me.txtFromNumber
lngTo = Me.txtToNumber

For lngCounter = lngFrom To lngTo
With rst
.AddNew
![Client_Code] = Me.txtClientCode
![Invoice_No- = lngCounter '<- May need to think about data type
here
'If you need to populate other fields and have the data, they
could go here
.Update
End With
Next LngCounter

rst.Close
Set rst = Notihing
Se dbf = Nothing
 
Top