Recordset based on Query

W

Wahab

Hi,
I want to write recordset based on query, selected records I want to write
to another table, for that
I open rTarget recordset in that table I wnat to write the records
sellected by query, But it is not working
please help me how i will write this recordset:

Dim StrSQL as String

StrSQL= " SELECT D.InvoiceNo, D.ProductID, D.ItemPrice, D.SaleAmount," & _
" D.SaleCopAmount FROM tCoptInvoices" & _
" INNER JOIN tCoptInvoicesDetails D ON tCoptInvoices.InvoiceNo =
D.InvoiceNo " & _
" WHERE Date Between # " & [Forms]![Startup
Dialog]![BeginningDate] & " # And # " & [Forms]![Startup
Dialog]![EndingDate] & " # "

Set rst = CurrentDb.OpenRecordset(StrSQL)
Set rTarget = CurrentDb.OpenRecordset("tInvoicesDetails")

Do Until rst.EOF
rTarget.AddNew
rTarget!InvoiceNo = rst!InvoiceNo
rTarget!ProductID = rst!ProductID: rTarget!Cartons =
rst!Cartons
rTarget!ItemPrice = rst!ItemPrice: rTarget!SaleAmount
= rst!SaleAmount
rTarget.Update
rst.MoveNext
Loop
rst.Close
 

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

Similar Threads

Recordset Problem 3
Recordset Based on Select Query 2

Top