Results 1 to 2 of 2

Thread: Problem with Null

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Lewiston, Maine
    Posts
    128

    Problem with Null

    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

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036
    Hi
    Try this

    If IsNull(adoprimaryrs!totalfld12 ) Then

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width