Results 1 to 4 of 4
  1. #1
    wlkr.jk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    20

    Check box to if statement issues

    Hi,

    I'm having some issues making my if statement properly read the input from the check boxes I have set up.



    I have 2 checkboxes set up in my form. One is "chkOverdue" and the other is "chkOnTime".

    This is the code I'm using:
    Code:
        If Me.chkOnTime = -1 And Me.chkOverdue = 0 Then        
            tempOnTime = " AND [DatetobeClosed]>Date()"
        ElseIf Me.chkOnTime = 0 And Me.chkOverdue = -1 Then
            tempOnTime = " AND [DatetobeClosed]<=Date()"
        Else
            tempOnTime = ""
        End If
    I've also tried using True (in place of -1) and False (in place of 0) and that doesn't work either. Regardless of what combination is checked off on the checkboxes, the code always goes to the else statement.

    Thanks

  2. #2
    wlkr.jk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    20
    So I did some further investigation.

    Even though Triple state was disabled, it seemed to automatically default to null instead of 0. I didn't even consider this because triple state was disabled.

    None the less, this doesn't seem right. All I did was set the default value of both check boxes to 0....does anyone know why I have to do this?

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Is the Checkbox Bound to a Field in the underlying Table/Query? If it is Unbound, it will exhibit this behavior if it is never ticked; once ticked then unticked the value will be 0.

    If this is the case you can use something like

    If Me.chkOnTime = -1 And Me.chkOverdue <> -1 Then

    Linq ;0)>

  4. #4
    wlkr.jk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    20
    Not bound.

    Great thanks.

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

Similar Threads

  1. Replies: 5
    Last Post: 06-26-2014, 12:52 PM
  2. Using Check boxes for an if statement
    By brow1726 in forum Forms
    Replies: 3
    Last Post: 06-10-2013, 09:50 PM
  3. Replies: 5
    Last Post: 07-17-2012, 12:18 PM
  4. Check my Select Statement in Form
    By OMGsh Y did I say Yes in forum Forms
    Replies: 12
    Last Post: 12-07-2010, 02:13 PM
  5. Check Box issues
    By data123 in forum Forms
    Replies: 0
    Last Post: 01-03-2007, 03:21 PM

Tags for this Thread

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