J
Jean
Hi,
First I did not create this. The following code is a
funtion that the form calls. It seems like it is working
and at the very end it gives me this error in
Ivo_Sum_ADJ94 Invalid use of null. I can see the error
handler say MsgBox "Error in " & "ivo_sum_adj" what does
the 94 represent.. When I debug and run the output it
looks like everything has populated into the tables so I
am not sure what this error is and what to look for to fix
it.
Thanks for any help!
Public Sub ivo_sum_adj(m, y)
On Error Resume Next
Dim xsql
Dim xrs As Recordset
Dim ter
Dim cat
Dim mamt As Double
Dim yamt As Double
sql = "select TERR1,CATEGORY from tbl_ivo_ytd group by
TERR1,CATEGORY order by TERR1"
Set rs = CurrentDb.OpenRecordset(sql)
Do Until rs.EOF
ter = rs!TERR1
cat = rs!category
xsql = "select AMT from
tbl_ivo_summary where category='" & cat & "' and TERR1='"
& ter & "'"
Set xrs = CurrentDb.OpenRecordset
(xsql)
Debug.Print xsql
If xrs.EOF = True And xrs.BOF =
True Then
mamt = 0
Else
mamt = xrs!amt
End If
xrs.Close
Set xrs = Nothing
xsql = "select sum(AMT)as am from
tbl_ivo_ytd where category='" & cat & "' and TERR1='" &
ter & "' and TRADE_MONTH<=" & m & " and TRADE_YEAR=" & y
& ""
Set xrs = CurrentDb.OpenRecordset
(xsql)
If xrs.EOF = True And xrs.BOF =
True Then
Else
yamt = xrs!am
End If
xrs.Close
Set xrs = Nothing
xsql = "select * from
tbl_rpt_sale_goal where TERR1='" & ter & "' and
category='" & cat & "'"
Set xrs = CurrentDb.OpenRecordset
(xsql)
If Not xrs.EOF Then
xrs.Edit
xrs!sales = xrs!sales - mamt
xrs!ytd_sales = xrs!ytd_sales -
yamt
xrs.Update
End If
xrs.Close
Set xrs = Nothing
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
If Err.Number <> 0 Then
MsgBox "Error in " & "ivo_sum_adj" & Err.Number &
Err.Description
End If
End Sub
First I did not create this. The following code is a
funtion that the form calls. It seems like it is working
and at the very end it gives me this error in
Ivo_Sum_ADJ94 Invalid use of null. I can see the error
handler say MsgBox "Error in " & "ivo_sum_adj" what does
the 94 represent.. When I debug and run the output it
looks like everything has populated into the tables so I
am not sure what this error is and what to look for to fix
it.
Thanks for any help!
Public Sub ivo_sum_adj(m, y)
On Error Resume Next
Dim xsql
Dim xrs As Recordset
Dim ter
Dim cat
Dim mamt As Double
Dim yamt As Double
sql = "select TERR1,CATEGORY from tbl_ivo_ytd group by
TERR1,CATEGORY order by TERR1"
Set rs = CurrentDb.OpenRecordset(sql)
Do Until rs.EOF
ter = rs!TERR1
cat = rs!category
xsql = "select AMT from
tbl_ivo_summary where category='" & cat & "' and TERR1='"
& ter & "'"
Set xrs = CurrentDb.OpenRecordset
(xsql)
Debug.Print xsql
If xrs.EOF = True And xrs.BOF =
True Then
mamt = 0
Else
mamt = xrs!amt
End If
xrs.Close
Set xrs = Nothing
xsql = "select sum(AMT)as am from
tbl_ivo_ytd where category='" & cat & "' and TERR1='" &
ter & "' and TRADE_MONTH<=" & m & " and TRADE_YEAR=" & y
& ""
Set xrs = CurrentDb.OpenRecordset
(xsql)
If xrs.EOF = True And xrs.BOF =
True Then
Else
yamt = xrs!am
End If
xrs.Close
Set xrs = Nothing
xsql = "select * from
tbl_rpt_sale_goal where TERR1='" & ter & "' and
category='" & cat & "'"
Set xrs = CurrentDb.OpenRecordset
(xsql)
If Not xrs.EOF Then
xrs.Edit
xrs!sales = xrs!sales - mamt
xrs!ytd_sales = xrs!ytd_sales -
yamt
xrs.Update
End If
xrs.Close
Set xrs = Nothing
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
If Err.Number <> 0 Then
MsgBox "Error in " & "ivo_sum_adj" & Err.Number &
Err.Description
End If
End Sub