Results 1 to 5 of 5
  1. #1
    VSCurtis is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Dec 2014
    Posts
    65

    Invalid Use Of Nulll Error Message When Checking To See If LongText Field Has Data

    Hi Guys,



    Just ran into a strange error and I'm hoping someone can tell me what's going on. I have a procedure that basically pulls the data from the current record and places it in the correct control on my form. No problems until I try to pull the data for the Description field and put it in a textbox field on my form. My code does a null check on the Description field and produces an Invalid Use of Null Error Message. This makes no sense since I'm checking for Null but I know it has something to do with the screwy nature of the null value itself. Basically, the routine just goes field by field and checks if data is available in that field. If so the data is placed in the control. If not the control is set to a cleared state. Here's the code. Any help you can provide is appreciated.

    Code:
    Private Sub LoadCardFields()
    txtCardName.SetFocus
    If Not IsNull(rs("Card Name")) Then
       txtCardName.Text = rs("Card Name")
    Else
       txtCardName.Text = vbNullString
    End If
    If Not IsNull(rs("Category ID")) Then
       cmbCardCategory.Value = rs("Category ID")
    Else
       cmbCardCategory.Value = -1
    End If
    If Not IsNull(rs("Attribute ID")) Then
       cmbCardAttribute.Value = rs("Attribute ID")
    Else
       cmbCardAttribute.Value = -1
    End If
    txtLevel.SetFocus
    If Not IsNull(rs("Level")) Then
       txtLevel.Text = rs("Level")
    Else
       txtLevel.Text = vbNullString
    End If
    If Not IsNull(rs("Monster Type ID")) Then
       cmbMonsterType.Value = rs("Monster Type ID")
    Else
       cmbMonsterType.Value = -1
    End If
    txtAttackPoints.SetFocus
    If Not IsNull(rs("Attack Points")) Then
       txtAttackPoints.Text = rs("Attack Points")
    Else
       txtAttackPoints.Text = vbNullString
    End If
    txtDefensePoints.SetFocus
    If Not IsNull(rs("Defense Points")) Then
       txtDefensePoints.Text = rs("Defense Points")
    Else
       txtDefensePoints.Text = vbNullString
    End If
    If Not IsNull(rs("Card Type ID")) Then
       lstCardType.Value = rs("Card Type ID")
    Else
       lstCardType.Value = -1
    End If
    txtPendulumScale.SetFocus
    If Not IsNull(rs("Pendulum Scale")) Then
       txtPendulumScale.Text = rs("Pendulum Scale")
    Else
       txtPendulumScale.Text = vbNullString
    End If
    txtLevel.SetFocus
    If Not IsNull(rs("Level")) Then
       txtLevel.Text = rs("Level")
    Else
       txtLevel.Text = vbNullString
    End If
    txtDescription.SetFocus
    If Not IsNull("Description") Then
       txtDescription.Text = rs("Description")
    Else
       txtDescription.Text = vbNullString
    End If
    If Not IsNull("Forbidden") Then
       chkForbidden.Value = rs("Forbidden")
    Else
       chkForbidden.Value = False
    End If

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Maybe this:
    If Not IsNull(rs("Description")) Then
    txtDescription.Text = rs("Description")

  3. #3
    VSCurtis is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Dec 2014
    Posts
    65
    Opps, my bad Dave. Thanks for catching my typo. It worked. Think I've been staring at this code for too long

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    We all fall into that trap. Glad to add a pair of eyes.

  5. #5
    VSCurtis is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Dec 2014
    Posts
    65
    Yep, the mind sometimes sees what it wants to see, not what's there. An extra pair of eyes does wonders. Thanks for the assist. Let me know if I can return the favor. I'm sure some of the field names in my code looked a bit odd. In case you're wondering, I am designing a Yu-Gi-Oh Trading Card database.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error checking query and message
    By Jen0dorf in forum Access
    Replies: 3
    Last Post: 11-10-2015, 09:05 AM
  2. Replies: 3
    Last Post: 01-20-2015, 01:35 PM
  3. Invalid value error field ‘ID’
    By Lina72 in forum Access
    Replies: 4
    Last Post: 08-26-2014, 01:16 PM
  4. Invalid Argument Error Message
    By kcochran130 in forum General Chat
    Replies: 1
    Last Post: 05-30-2013, 08:20 AM
  5. Error checking field, SetFocus does not work
    By SemiAuto40 in forum Access
    Replies: 9
    Last Post: 07-26-2011, 10:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums