I'm using this code to sum a currency field in a table. The results are put into a text box called Text12.text. My problem is when the result of the sum is 0 I get an error: Invalid use of Null. I have tried to test for a value of 0 as you can see, but I still get the same error.


VB Code:
  1. Set adoprimaryrs = New Recordset
  2. db.CursorLocation = adUseClient
  3. ssql = "SELECT SUM (Amount) as totalfld12 from donations where year(date) = Year(Date()) AND month(date) = 12"
  4.  adoprimaryrs.Open ssql, db, adOpenStatic, adLockOptimistic
  5. If adoprimaryrs!totalfld12 = "" Then
  6. Text12.Text = 0
  7. Else
  8.  
  9. Text12.Text = adoprimaryrs!totalfld12
  10. End If