M
mike
Any suggestions with this problem would be great. My
looping command which sends emails to employees is
terminated midway because the recordset item doesn't have
a match in another query that contains the data.
The recordset is a table of employees. The looping
command goes through the table of employees and sets the
filter for the datasets, like so:
Set rs = Db.OpenRecordset("SELECT * " & _
"FROM [tblMain]")
If Not rs.EOF Then
Do While Not rs.EOF
Set rsPFR = Db.OpenRecordset("SELECT * " & _
"FROM [tblProducts] " & _
"WHERE [Product]='PFR' And [Territory]='" & rs!
[Territory] & "'")
Set rsHTA = Db.OpenRecordset("SELECT * " & _
"FROM [tblProducts] " & _
"WHERE [Product]='HTA' And [Territory]='" & rs!
[Territory] & "'")
LBDValuePFR = rsPFR![LBDDollarsShipped]
MTDValuePFR = rsPFR![MTDDollarsShipped]
QTDValuePFR = rsPFR![QTDDollarsShipped]
LBDValueHTA = rsHTA![LBDDollarsShipped]
MTDValueHTA = rsHTA![MTDDollarsShipped]
QTDValueHTA = rsHTA![QTDDollarsShipped]
MsgTOT = LBDValuePFR + LBDValueHTA
DoCmd.SendObject acSendNoObject, , , Email, , ,
DaysOfMonth & rs![Territory], MsgTOT, False
Loop
End If
The tblProducts table looks something like this:
Name Product Sales
South PFR 100
South HTA 100
North PFR 200
East HTA 100
East PFR 100
Almost every employee has sales of PFR and HTA. The
problem is that there's one or two who have no HTA sales,
so when loop gets to...
"WHERE [Product]='HTA' And [Territory]='" & rs!
[Territory] & "'")
....and tries to make the calulation at...
LBDValueHTA = rsHTA![LBDDollarsShipped]
....it looks for the tblMain territory's HTA value, can't
find one, and the procedure ends. I can't figure out how
to tell the procedure that if there's no value, then just
set LBDValueHTA to zero. Using Nz doesn't work because
there's not even a null value...there's no value at all.
I'm stuck on this one. Any suggestions would be a real
help. Thanks!!
looping command which sends emails to employees is
terminated midway because the recordset item doesn't have
a match in another query that contains the data.
The recordset is a table of employees. The looping
command goes through the table of employees and sets the
filter for the datasets, like so:
Set rs = Db.OpenRecordset("SELECT * " & _
"FROM [tblMain]")
If Not rs.EOF Then
Do While Not rs.EOF
Set rsPFR = Db.OpenRecordset("SELECT * " & _
"FROM [tblProducts] " & _
"WHERE [Product]='PFR' And [Territory]='" & rs!
[Territory] & "'")
Set rsHTA = Db.OpenRecordset("SELECT * " & _
"FROM [tblProducts] " & _
"WHERE [Product]='HTA' And [Territory]='" & rs!
[Territory] & "'")
LBDValuePFR = rsPFR![LBDDollarsShipped]
MTDValuePFR = rsPFR![MTDDollarsShipped]
QTDValuePFR = rsPFR![QTDDollarsShipped]
LBDValueHTA = rsHTA![LBDDollarsShipped]
MTDValueHTA = rsHTA![MTDDollarsShipped]
QTDValueHTA = rsHTA![QTDDollarsShipped]
MsgTOT = LBDValuePFR + LBDValueHTA
DoCmd.SendObject acSendNoObject, , , Email, , ,
DaysOfMonth & rs![Territory], MsgTOT, False
Loop
End If
The tblProducts table looks something like this:
Name Product Sales
South PFR 100
South HTA 100
North PFR 200
East HTA 100
East PFR 100
Almost every employee has sales of PFR and HTA. The
problem is that there's one or two who have no HTA sales,
so when loop gets to...
"WHERE [Product]='HTA' And [Territory]='" & rs!
[Territory] & "'")
....and tries to make the calulation at...
LBDValueHTA = rsHTA![LBDDollarsShipped]
....it looks for the tblMain territory's HTA value, can't
find one, and the procedure ends. I can't figure out how
to tell the procedure that if there's no value, then just
set LBDValueHTA to zero. Using Nz doesn't work because
there's not even a null value...there's no value at all.
I'm stuck on this one. Any suggestions would be a real
help. Thanks!!