
Signature
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
>I want to loop through a recordset and capture the value in a field. There
> could be as many as 18 records..... do I declare strValue1, strValue2..
[quoted text clipped - 3 lines]
>
> Thanks for your help!
Hi Allen - no not to sum, I want to copy an existing recordset and then copy
it to a new one (contract information that usually does not change from
contract year to year).
Is there a way to copy the entire recordset an assign it a new ID number?
That might be more efficient, since the number of records will vary.
Thanks -
> What is the purpose of looping through the records?
> To sum them?
[quoted text clipped - 9 lines]
> >
> > Thanks for your help!
Allen Browne - 20 Jan 2006 14:46 GMT
Can you make a query that gives you the records you want to duplicate?
If you can, do so, and then turn it into an Append query (Append on Query
menu). Access asks what table you want to append to (which may actually be
the same table.)
When you run the query, the records are created for you.
If you want to do that programmatically, when you have the query working
correctly, switch it to SQL View (View menu.) You now have an Update query
statement to copy into your code. The code will be like this:
Dim strSql As String
strSql = "INSERT INTO ...
dbEngine(0)(0).Execute strSql, dbFailOnError

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
> Hi Allen - no not to sum, I want to copy an existing recordset and then
> copy
[quoted text clipped - 20 lines]
>> > am
>> > lost.
Anne - 20 Jan 2006 16:41 GMT
Great. But I would need to change the key field value - appending it as is
would cause a duplication error...... is that possible?
> Hi Allen - no not to sum, I want to copy an existing recordset and then copy
> it to a new one (contract information that usually does not change from
[quoted text clipped - 18 lines]
> > >
> > > Thanks for your help!
Allen Browne - 20 Jan 2006 17:24 GMT
In query design view, if you have the AutoNumber field in the grid, make
sure the Append To beneath it is blank.
Access will automatically assign the new autonumber, as long as you are not
trying to append a value here.

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
> Great. But I would need to change the key field value - appending it as
> is
[quoted text clipped - 24 lines]
>> > > am
>> > > lost.