Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return a value

Status
Not open for further replies.

ecugrad

MIS
Apr 17, 2001
191
US
I have the below SQL Statement behind my form. I want my txtAugust field to show 0 if I don't have any entries in the table for the selected employee. I will use the zero for other equations. My problem is if there is not an entry I'm can't get a zero returned..

strSQL = "SELECT Sum(G1+G2+P1+P2+P3+P4+P5+P6+P7+TC1+TC2+TC3+TC4+TC5+TC6+TC7+C1+C2+C3+C4+K1+K2)AS newCallTotals FROM tblNewCallMon "
strSQL = strSQL & "WHERE ((tblNewCallMon.EmployeeID)= " & EmployeeID & ")AND ((tblNewCallMon.CallDate) Between #08/01/02# AND #08/31/02#) ;"
Set rs = Db.OpenRecordset(strSQL, dbOpenSnapshot)

If rs!newCallTotals = "" Or IsEmpty(rs!newCallTotals) Or (rs!newCallTotals) = 0 Then
rs!CallTotals = "0"
Else

frm!txtAugust = rs!newCallTotals
rs.Close
strSQL = "'"

End If

Thanks,

Mike
 
Check the eof property of the recordset. If true, no records returned. Therefore, set the value to 0.

Set rs = Db.OpenRecordset(strSQL, dbOpenSnapshot)

if (rst.eof) then
txtAugust = 0
else
blah...blah...blah
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top