Results 1 to 9 of 9
  1. #1
    ThunderSpark is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2017
    Posts
    32

    Cannot set ALL Filter_Checks to Default Value False: Only one gets set to false

    This topic is kind of related to this one: https://www.accessforums.net/showthread.php?t=77041. Because I am using the same basic code and Idea, mainly this:



    Code:
    Dim strCheck     As String
    strCheck = getValuefromTable("SELECT ROL FROM ADMIN_ROLLEN WHERE GEBRUIKER = '" & Environ("USERNAME") & "'")
        If Environ("USERDOMAIN") = "XXXX" And strCheck = "Admin" Then
    
        Else
            If Environ("USERDOMAIN") = "XXXX" And strCheck = "BIB" Then
    
            Else
    
            End If
        End If
    Now I know there is another possible solution by islagdogs, to set up controls to make it easier, I am just using that code as base. And I want to use his solution another day.

    isladogs.

    Here is the Deal: I want to set some Certain Filter Checks that make sure the Doc Manager Database searches into certain folders. However there will be certain Group of Users Called BIB who only need to search in the Library and not inside the network. So for those users it would be best those Filter Checks have the default value of 0. These Filters are part of a Sub Forum where the Column Name is Filter Check and the Field Name is Filter Check2.
    Now I have written this in code:

    Code:
    Private Sub Form_Load()
    Dim strCheck     As String
    strCheck = getValuefromTable("SELECT ROL FROM ADMIN_ROLLEN WHERE GEBRUIKER = '" & Environ("USERNAME") & "'")
        If Environ("USERDOMAIN") = "XXXX" And strCheck = "Admin" Then
        FILTER_CHECK2 = True
        Else
            If Environ("USERDOMAIN") = "XXXX" And strCheck = "BIB" Then
            FILTER_CHECK2 = False
            Else
            FILTER_CHECK2 = False
            End If
        End If
    End Sub
    And so far it seems to work but with one Problem: The code only disables one of the four Filter Checks.
    Click image for larger version. 

Name:	Naamloos.png 
Views:	21 
Size:	136.3 KB 
ID:	38870


    Any reason why this is Happening? I know the Subform pulls from and Selects from Querry as source and each Filter Check has his own ID but that should not be the issue.

  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,518
    Your code would only affect the selected (or first) record, so not surprising. If the values are the only ones in a table, or can be identified by a criteria, run an update query that updates the field and then requery the subform.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ThunderSpark is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2017
    Posts
    32
    Quote Originally Posted by pbaldy View Post
    Your code would only affect the selected (or first) record, so not surprising. If the values are the only ones in a table, or can be identified by a criteria, run an update query that updates the field and then requery the subform.
    How do you program that in Visual Basic?

  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,518
    Presuming all records:

    CurrentDb.Execute "UPDATE TableName SET FieldName = False", dbFailOnError
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    ThunderSpark is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2017
    Posts
    32
    Quote Originally Posted by pbaldy View Post
    Presuming all records:

    CurrentDb.Execute "UPDATE TableName SET FieldName = False", dbFailOnError
    No it does not work it is strange though the code works for every Form and the Subform and therefore the Filter Check2 is set to False but even loading up, it does not matter why I post the code FRM Main.
    SubForm Admin Folders Documents. On The Forum that Loads (and even there the code is there) when you open the database Filter Check 2 is still enabled even though when I load the subform seperatly there are set on False What is going on here?

    Click image for larger version. 

Name:	Naamloos2.jpg 
Views:	15 
Size:	120.7 KB 
ID:	38887

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You may also need to requery the subform. Where is the code running? You just have to refer to the subform appropriately:

    http://theaccessweb.com/forms/frm0031.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    ThunderSpark is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2017
    Posts
    32
    Quote Originally Posted by pbaldy View Post
    You may also need to requery the subform. Where is the code running? You just have to refer to the subform appropriately:

    http://theaccessweb.com/forms/frm0031.htm
    I have found the error. Apparantly there already was a CurrentDb.Execute "UPDATE TableName SET FieldName = True", dbFailOnError. In the exisiting code on the Forum that gets loaded when it starts.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Glad you got it sorted.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    ThunderSpark is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2017
    Posts
    32
    Quote Originally Posted by pbaldy View Post
    Glad you got it sorted.
    Still thank you for the help.

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

Similar Threads

  1. Replies: 8
    Last Post: 10-06-2014, 03:02 PM
  2. True And False
    By azhar2006 in forum Forms
    Replies: 4
    Last Post: 12-23-2013, 03:50 AM
  3. SELECT "False" if any records are false?
    By Azurewrath in forum Queries
    Replies: 6
    Last Post: 12-21-2011, 03:36 PM
  4. FilterOn = False
    By ybg1 in forum Forms
    Replies: 1
    Last Post: 06-21-2011, 01:23 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