Results 1 to 4 of 4
  1. #1
    athomas8251 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    10

    Error 94: Invalid Use of Null

    Assistance please! I have a comment field that in some instances, always requires the user to enter a note.



    There is one instance however, when notes shouldn't be entered.

    Case 1, 2, 6 work great.

    I never had a Case 5 and users always enter notes into it. Here's what I am trying to do:

    If the 'status' comment has anyting in it, show a message, select the text (for cut/paste), then once text is removed, allow the record to be added.

    Here's the VBA. I highlighted what I was trying to do.

    Code:
     
     
    Private Sub AddButton_Click()
    Dim MatTotal As Variant ' current material total
    Dim CurCode As String ' current referral code
    Dim db As Database ' current DB
    Dim rs As Recordset ' tActivity
     
    [[ bunch of stuff snipped that doesn't apply ]]
     
    Select Case Me.Activity ' get activity type code
    Case 1, 2, 6 ' IB, OB, or Update/Close
    If IsNull(Me.ActivityComment) Or Me.ActivityComment = "" Then
    MsgBox "You must enter the Activity Comment."
    Me.ActivityComment.SetFocus ' goto field
    Exit Sub ' bail out
    End If '
    Me.ActivityComment.SetFocus ' go to action field
    Me.ActivityComment.SelStart = 0 ' set insertion point to start of text
    Me.ActivityComment.SelLength = Len(Me.ActivityComment) ' selecte all Text
    DoCmd.RunCommand acCmdSpelling ' spell check field
     
    MY ATTEMPT: 
     
    Case 5 ' Status comment
    If Not IsNull(Me.ActivityComment ???????????
    MsgBox "You cannot enter a comment on Status. Cut and paste to IB or OB note instead"
    Me.ActivityComment.SetFocus ' goto field
    Exit Sub ' bail out
    End If '
    Me.ActivityComment.SetFocus ' go to action field
    Me.ActivityComment.SelStart = 0 ' set insertion point to start of text
    Me.ActivityComment.SelLength = Len(Me.ActivityComment) ' selecte all Text
    Thanks for looking at this!

    Andi

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Test for Null should be enough.
    If Not IsNull(Me.ActivityComment) Then

    You want to copy to clipboard? Check http://bytes.com/topic/access/answer...pboard-via-vba

    And if need to, set textbox to Null
    Me.ActivityComment = Null
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    If you don't have ALLOW ZERO LENGTH set to NO in that field then you should really use

    If Len(Me.ActivityComment & vbNullString) > 0 Then

  4. #4
    athomas8251 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    10
    Thank you Bob. That worked. Problem solved!

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

Similar Threads

  1. CInt and Invalid Use of Null
    By drewetzel in forum Access
    Replies: 4
    Last Post: 10-21-2011, 03:52 PM
  2. StrComp causing "Invalid use of Null" error
    By sephiroth2906 in forum Programming
    Replies: 5
    Last Post: 09-15-2011, 07:06 PM
  3. DLookUp function giving invalid use of null error
    By shubhamgandhi in forum Programming
    Replies: 4
    Last Post: 07-21-2011, 06:04 PM
  4. Invalid use of Null
    By Wayne311 in forum Programming
    Replies: 4
    Last Post: 01-27-2011, 05:10 PM
  5. Invalid Use of Null!?!
    By Kipster1203 in forum Access
    Replies: 4
    Last Post: 05-13-2010, 06:09 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