Appending one row at a time

G

Guest

I have a VBA that runs a query and appends the part numbers from one table to
another table. The VBA contains a loop that executes while not end of table.
I want to be able to append one row from the parts table at a time. Is this
possible?
 
G

Guest

Is it that you would like to interact, with the db, between each update? If
so, the simple solution would seem to be to remove the loop.

Sharkbyte
 
G

Guest

There are nine items in the part number table. When I run the VBA with the
loop, those nine items are appended nine times, for a total of 81 items in
the new table. Without the loop the nine items are all appended, but I want
to be able to just append one of the rows at a time, if this is possible?
BK
 
G

Guest

There is something wrong in your loop. You are not distinctly identifying
each row, and so it runs the append for all 9 records. Then, when it moves
to the next record, and cannot uniquely identify each record, it appends all
9 again; etc, until the loop completes.

You need to add a unique identifier, for each record, to the loop criteria.
This way the loop only process one record on each pass.

Sharkbyte
 
G

Guest

Thanks for the advice, I've been making progress but it still isn't
completely working, do you happen to have any specific examples of what to
add to the loop?
 
G

Guest

Public Function vAppendPartNumbers()
Dim rstTestParts As Recordset
Set rstTestParts = CurrentDb().OpenRecordset("TestParts")
g_strPartNumber = rstTestParts![PartNumber]
DoCmd.OpenQuery ("TestQueryDelete")
While Not rstTestParts.EOF
DoCmd.OpenQuery ("TestQuery2")

rstTestParts.MoveNext

Wend

here is the loop, could the problem be with the query?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top