Help with an update query in Access 2003 |
Author |
Message |
|
Posted : 2007-02-14 17:02:29 |
My quickbooks 2006 file has approx 11,000 invoices/records in the Invoice table. I need to reprint approx 1200 nonsequential invoices so I have created a table in access that has the 1200 invoice numbers. I was going to join the two tables based on refnum and invoice number and update the Istobeprinted field in the invoice table to '1'. The query runs for hours and hours and just hangs. What optimization and/or SQL syntax should I be using. All the invoices are post nov 06 if that is any help. |
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2007-02-14 21:06:12 |
Basically you are going to need to setup a programming loop that reads each invoice number and executes:
DoCmd.RunSQL "UPDATE Invoice SET IsToBePrinted=1 where RefNumber = [invoice number variable]"
If you're saying that you just want to reprint everything after Nov'06 then you could just run this SQL Statement using VB Demo:
UPDATE Invoice SET IsToBePrinted=1 where TxnDate > {d'2006-11-30'} |
|
|
|
|
Posted : 2007-02-15 11:10:49 |
thanks, although i know access and sql i dont know how to do a loop. so i am kind of stuck. I was hoping to link tables together to run the query. Unfortunately i am also not just trying to print all the invoices post nov, that is just an earliest date. any resources i can look at that would give me the code for running through a table row by row and run your code? |
|
|
|
|
Posted : 2007-02-15 11:31:18 |
does this look ok?
----------------------------
Private Sub Command5_Click()
dim rs as DAO.Recordset dim i as long
set rs = currentdb.openrecordset(Tablename,dbOpendynaset) rs.movelast i = rs.AbsolutePosition
do while i >=0
DoCmd.RunSQL "UPDATE Invoice SET IsToBePrinted=1 where RefNumber = [WorkTbl]![inv#]"
rs.moveprevious i = i - 1
loop
set rs = nothing
End Sub |
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2007-02-15 14:23:29 |
This FREE QODBC support forum is limited to QODBC. If you need help with MS Access/QODBC programming, we have fee based solutions starting at A$154.00 per hour (charges apply), click here for more information. |
|
|
|