Results 1 to 5 of 5
  1. #1
    S2000magician is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    31

    Identifying a null value in a combo box

    I have a combo box whose dropdown menu contains dates.

    I discovered that if the user doesn't select a date from the dropdown menu (e.g., clicks on the dropdown menu, then clicks somewhere else), then the combo box value is Null.

    When I try to test for a null value (i.e., If combo_box_1.Value = Null Then . . . .), it never recognizes the null value; it doesn't execute the "Then . . . ." code.

    So . . . how can I identify a null value in a combo box?

    Thanks, guys! This one's vexing me.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Cannot compare anything to null, will always return Null, not True or False, even Null = Null.

    Review http://allenbrowne.com/casu-12.html
    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
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If you think of Null as "unknown", you'll realize that nothing can ever be "equal to" it. Try

    If IsNull(combo_box_1.Value) Then

    or this which tests for both Null and a zero length string:

    If Len(combo_box_1.Value & vbNullString) = 0 Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    S2000magician is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    31
    Quote Originally Posted by pbaldy View Post
    If you think of Null as "unknown", you'll realize that nothing can ever be "equal to" it. Try

    If IsNull(combo_box_1.Value) Then

    or this which tests for both Null and a zero length string:

    If Len(combo_box_1.Value & vbNullString) = 0 Then
    Awesome, Paul!

    (Thanks, too, to June7.)

    That did the trick!

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Check two combo box if null
    By margzj in forum Access
    Replies: 17
    Last Post: 08-19-2017, 08:10 AM
  2. Replies: 2
    Last Post: 06-30-2016, 10:51 AM
  3. Combo box to show all results if null
    By Ruegen in forum Forms
    Replies: 3
    Last Post: 07-25-2014, 12:06 AM
  4. Combo is Null Function Help
    By fabian1675 in forum Forms
    Replies: 1
    Last Post: 02-10-2012, 05:57 PM
  5. Need help identifying what to do....?
    By shands in forum Access
    Replies: 7
    Last Post: 09-29-2011, 11:49 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