HAPPY NEW YEAR TO ALL!!
Can anyone quickly see why the code aborts at the debug line ?
Can anyone quickly see why the code aborts at the debug line ?
Code:
Private Sub Command2_Click()
DoCmd.OpenQuery "weeklytotallabor"
DoCmd.OpenQuery "weeklytotalmatl"
' get weekly totals of labor + materials for CUSTOMER
DoCmd.RunSQL ("delete * from weeklygraph;")
DoCmd.RunSQL "insert into weeklygraph (custname, yearweeknumber, sumlabor) select cust, yearweeknumber, sumoflabor from weeklytotallabor;"
DoCmd.RunSQL "insert into weeklygraph (custname, yearweeknumber, summatl) select customer, yearweeknumber, sumofmatl from weeklytotalmatl;"
DoCmd.Close acTable, "weeklygraph", acSaveYes
DoCmd.Close acQuery, "weeklytotalLabor", acSaveYes
DoCmd.Close acQuery, "weeklytotalMatl", acSaveYes
On Error GoTo ErrorHandler
Dim db As DAO.Database
Dim rstquery As DAO.Recordset
Dim rsttable As DAO.Recordset
Set db = CurrentDb
' Close ("weeklytotalmatl")
Set rsttable = db.OpenRecordset("weeklygraph")
' *** CODE ABORTS AT THE NEXT LINE ***
Set rstquery = db.OpenRecordset("weeklytotalMatl")
rstquery.MoveFirst
Do Until rstquery.EOF
' rstprep.Update
' Update table code will be added next
rstquery.MoveNext
Loop
'_________________________________
On Error GoTo ErrorHandler
ErrorHandlerExit:
quitnow:
Exit Sub
ErrorHandler:
If Err = 3021 Then ' no current record
Else
' MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End If
DoCmd.OpenReport "weeklytotalgraph", acViewPreview
End Sub