Results 1 to 12 of 12
  1. #1
    ggs is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    New Zealand
    Posts
    36

    OpenForm by Check Box False

    I have a check box [resolved] and a button to open reports unresolved.

    Private Sub cmdUnresolvedRpt_Click()
    Dim strWhere As String
    If Me.resolved = False Then


    strWhere = strWhere & " AND resolved=false" '
    Else
    strWhere = "[resolved] = " & Me.[resolved]
    DoCmd.OpenReport "rptIncListing", acViewPreview, , strWhere
    End If
    End Sub

    This opens the report with all the resolved records listed. Ha I thought changing false to true only to find that does nothing at all
    There is something wrong right oops did i say open form open report
    say what you mean don't mean what you say
    Last edited by ggs; 10-02-2011 at 12:39 AM. Reason: i meant open report

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Your OpenReport line is within the Else clause. I would expect it to be after the End If. As it is, it will only run when resolved is not false.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ggs is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    New Zealand
    Posts
    36
    changed that

    Private Sub cmdUnresolvedRpt_Click()
    Dim strWhere As String
    If Me.resolved = False Then
    strWhere = strWhere & " AND resolved = False" '
    Else
    strWhere = "[resolved] = " & Me.[resolved]
    End If
    DoCmd.OpenReport "rptIncListing", acViewPreview, , strWhere
    End Sub

    and now the records that show are only the true or checked box items
    and I am after the unchecked items

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    What is contained in Me.resolved? Your code is dependent on that value. Further, this line should not include the "AND" bit:

    strWhere = strWhere & " AND resolved = False" '
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    ggs is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    New Zealand
    Posts
    36
    resolved is field format check box
    also control on a form which is the record source for this report

  6. #6
    stmoong is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Location
    Singapore
    Posts
    108
    Would this work?

    Code:
    Private Sub cmdUnresolvedRpt_Click()
        Dim strWhere As String
        If Me.resolved = False Then
            strWhere = "resolved = False"
        Else
            strWhere = "resolved = True"
        End If
        DoCmd.OpenReport "rptIncListing", acViewPreview, , strWhere
    End Sub

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Actually based on what you're doing, you don't even need the If/Then, just:

    strWhere = "resolved = " & Me.resolved

    Did removing the "AND" help? Can you post the db if you're still having trouble?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    ggs is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    New Zealand
    Posts
    36
    Thank you all
    stmoong

    Private Sub cmdUnresolvedRpt_Click()
    Dim strWhere As String
    If Me.resolved = False Then
    strWhere = "resolved = False"
    Else
    strWhere = "resolved = False"
    End If
    DoCmd.OpenReport "rptIncListing", acViewPreview, , strWhere
    End Sub
    your original code gave me all the true results changeing the True to False in red worked
    I don't get it

    pbaldy
    removing the & and removing the if then also gave me all the true
    but any way (looks strange) but all fixed

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Surely you're not saying that the posted code works? It can't ever pull the True records.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    stmoong is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Location
    Singapore
    Posts
    108
    Quote Originally Posted by pbaldy View Post
    Actually based on what you're doing, you don't even need the If/Then, just:

    strWhere = "resolved = " & Me.resolved

    Did removing the "AND" help? Can you post the db if you're still having trouble?
    Yup, that will work. I was not sure if Access uses 0/1 or 0/-1 for boolean field (False/True), seems to be the latter (0 = False, -1 = True).


    ggs, regarding your statement about "changeing the True to False in red worked". It is as good as not having the If/Else, and just set the "resolved = False" since both conditions evaluate to the same result.

    Just in case, could you check the followings?
    - check the database column is of type Yes/No
    - before you click the button, did you uncheck the checkbox?

  11. #11
    ggs is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    New Zealand
    Posts
    36
    yes data is of Yes/No typr
    I am wanting to get the No False or 0 results. If the "Incident" is not yet resolved I want it to appear in a Report "Unresolved Incidents"
    The check box for resolved is on the main form I have a seperate form which has 8 command buttons for a number of different reports so the check box remains the way it has been selected until someone selects otherwise
    Anyway all is good and thankyou again for your help

  12. #12
    stmoong is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Location
    Singapore
    Posts
    108
    Well, if your checkbox is always checked, then it will always return you resolved = true, unless you specify the query to return resolved = false, which in this case, you don't really have to check the value of the check box...

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

Similar Threads

  1. FilterOn = False
    By ybg1 in forum Forms
    Replies: 1
    Last Post: 06-21-2011, 01:23 PM
  2. Enabled = False
    By Juan4412 in forum Forms
    Replies: 2
    Last Post: 04-19-2011, 06:05 PM
  3. Form combo box not working with AllowEdits = False
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 02-04-2011, 05:08 PM
  4. Yes/No True/False
    By DSTR3 in forum Access
    Replies: 5
    Last Post: 12-04-2010, 05:56 PM
  5. True or false
    By tleec in forum Queries
    Replies: 1
    Last Post: 02-01-2008, 10:41 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