Results 1 to 4 of 4
  1. #1
    schulzy175 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Posts
    98

    Whaa? Why is this skipping my True If-Statement??

    The value for me.outputtext.value is Null. How and why is the if-statement skipping/not noticing that the if-statement is true?? It skips the msgbox and goes to the "else".




    Click image for larger version. 

Name:	skip.png 
Views:	14 
Size:	4.0 KB 
ID:	33193

  2. #2
    schulzy175 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Posts
    98
    Code:
    isnull(me.outputtext.value) = true then
    Found the solution! I didn't know what to google so I didn't think I'd find the solution so quickly.

    reference: https://stackoverflow.com/questions/...x-null-problem

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Code:
    If Me.outputtext = NULL Then
    To answer your question about the above statement, NOTHING is equal to NULL, not even NULL!

    In the immediate window, if you type in
    ? 1 = 1 --> the result is TRUE
    ? 1 = 2 --> the result is FALSE
    ? NULL = NULL --> the result is NULL
    ? NULL = 2 --> the result is NULL
    Comparing anything to NULL results in a NULL return value.


    You can use:
    Code:
    If IsNull(Me.outputtext) Then.....  (<<-- this doesn't deal with an empty control .... ie where the control is "" )
    
    If NZ(Me.outputtext,"") = "" Then..... (<<--handles NULL or empty values)
    
    If Me.outputtext & "" = "" Then.....   (<<--handles NULL or empty values)
    
    If Len(Trim(Me.outputtext & "")) = 0 Then.....   (<<--number of characters in control)
    
    If Len(Trim(NZ(Me.outputtext,""))) > 0 Then.....  (<<--number of characters in control)
    I tend to use either of the last two.....

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    you don't need the = True and value is the default so zero need to use that either, just

    if isnull(me.outputtext) then

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

Similar Threads

  1. Replies: 2
    Last Post: 10-20-2015, 02:01 PM
  2. Replies: 7
    Last Post: 04-10-2014, 02:22 PM
  3. Replies: 7
    Last Post: 11-15-2013, 10:28 AM
  4. Replies: 2
    Last Post: 10-29-2012, 11:28 AM
  5. Replies: 7
    Last Post: 01-11-2012, 12:24 PM

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