Adding mutliple records....

edster

Registered User.
Local time
Today, 13:20
Joined
Sep 25, 2004
Messages
31
Hi, I’m looking for a bit of help. I have a form 'Holders' which has an autonumber field (holderID) with various other fields containing individual information.

What I am looking to do is have a form with four text fields "LotID";"Owner";"Location" and "NumberReceived"

Then a command button to run code which will add the records (all with same lot id etc) to a table for "numbereceived" amount of records. Ending up with say 25 identical records apart from the autonumber field being different.

Guessing I’m going to need a recordset and loop function but not sure how to go about it.....

Many thanks.
 
You can do it with a recordset, or you could build a query, setting criteria appropriately and group with the sigma symbol, group by "Sum."

dim db as dao.datbase
dim rs as dao.recordset
set db=currentdb
set rs=db.openrecordset("table, queryname, or SQL string,dbopensnapshot)
rs.movefirst
do until rs.eof

'do your calculations/summing here
'rs.field(0) througn rs.field(n) referes to the several recordset fields
'or
'rs!Fieldname1 rs!fieldNameN refers to the various fields

rs.movenext
loop
rs.close
set rs=nothing

Building queries are usually easiest for neophytes.
 

Users who are viewing this thread

Back
Top Bottom