patricktwo
Programmer
I am running a report and on the close I want to update a table in VBA. I am using the following SQL.
Private Sub Report_Close()
Dim strSQL As String
strSQL = "UPDATE checks set rptStateone = yes, pdToState = yes "
strSQL = strSQL & "WHERE (pdToState = no) AND (rptToState = NO) and (pdToPayee = no) AND "
strSQL = strSQL & "(amount < [Report]![firststatereporta]!remitAmt]) and "
strSQL = strSQL & "(checkDate < DateAdd('yyyy',-[Report]![firststatereporta]![nrYears], Date())) and "
strSQL = strSQL & "((ownID) IN (SELECT payeeID from payee WHERE payeestate = [Report]![firststatereporta]![stateAbr]))"
CurrentDb.Execute strSQL
End Sub
I keep getting a syntax error when I run it in the report.
Any help would be greatly appreciated.
Private Sub Report_Close()
Dim strSQL As String
strSQL = "UPDATE checks set rptStateone = yes, pdToState = yes "
strSQL = strSQL & "WHERE (pdToState = no) AND (rptToState = NO) and (pdToPayee = no) AND "
strSQL = strSQL & "(amount < [Report]![firststatereporta]!remitAmt]) and "
strSQL = strSQL & "(checkDate < DateAdd('yyyy',-[Report]![firststatereporta]![nrYears], Date())) and "
strSQL = strSQL & "((ownID) IN (SELECT payeeID from payee WHERE payeestate = [Report]![firststatereporta]![stateAbr]))"
CurrentDb.Execute strSQL
End Sub
I keep getting a syntax error when I run it in the report.
Any help would be greatly appreciated.