Filter Subform with Radio Buttons

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rhonda6373
    New Member
    • Mar 2010
    • 35

    Filter Subform with Radio Buttons

    Hello,

    I am trying to change a filter for a subform (Default) that has a filter based on a drop down box with a Search button to a filter based on radio buttons.

    However, I don't understand the current query enough to begin to change it. Here is the command that opens the query which has a subquery as well.

    Code:
    DoCmd.OpenQuery ("QryAccounts")
    Here is the part of the query I am having difficulty with:

    Code:
    FROM QryAccountsSub 
       LEFT JOIN ActiveUsers 
          ON QryAccountsSub.[Account Number] 
             = ActiveUsers.[Account Number]
    WHERE ((
       (QryAccountsSub.[Account Number])
          =IIf(IsNull([Forms]![Default]![Account])
             ,[QryAccountsSub].[Account Number]
             ,([Forms]![Default]![Account]))) 
           AND 
             ((QryAccountsSub.QQ)
                =IIf(IsNull([Forms]![Default]![st])
                ,[QQ]
                ,IIf([Forms]![Default]![st]="All"
                   ,[QQ]
                   ,IIf([Forms]![Default]![st]="Pre-Installed"
                      ,1
                      ,IIf([Forms]![Default]![st]="Q Accounts"
                         ,0
                         ,[QQ]))))) 
           AND
              ((QryAccountsSub.Act)
                =IIf(IsNull([Forms]![Default]![st])
                ,1
                ,IIf([Forms]![Default]![st]="All"
                   ,[Act]
                   ,IIf([Forms]![Default]![st]="Active Accounts"
                      ,1
                      ,[Act])))) 
           AND ((QryAccountsSub.LL)
                =IIf(IsNull([Forms]![Default]![st])
                   ,[LL]
                   ,IIf([Forms]![Default]![st]="All"
                      ,[LL]
                      ,IIf([Forms]![Default]![st]="Pre-Installed"
                      ,1
                      ,[LL])))))
    Here is the subquery:
    Code:
    SELECT Accounts.*
       , IIf(IsNull([Q Date])
             ,1
             ,0)
        AS QQ
       , IIf(IsNull([Live Date])
             ,1
             ,0) 
        AS LL
       , IIf(IsNull([Q Date]) 
             And [Live Date]<Date()+20
                ,1
                ,0)
        AS Act
    FROM Accounts
    ORDER BY Accounts.[Account Number];
    The combo box is named st and has 4 values: "All";"Pre-Installed";"Q Accounts";"Acti ve Accounts.

    Can anyone give me some insight into where/how to change values so that I can change from a combo box to radio buttons? Also, is there any way to simplify this? Thanks!
    Last edited by zmbd; Aug 27 '14, 09:12 PM. Reason: [z{stepped code and SQL for easier reading. Underlined the control and ctrl.name}]
  • rhonda6373
    New Member
    • Mar 2010
    • 35

    #2
    Hello,

    I figured this out. Rather than trying to understand this query, I just replaced the values "All";"Pre-Installed";"Q Accounts";"Acti ve Accounts" in the query with 1,2,3,4 and renamed the radio button frame to st. It appears to work.

    Thanks!

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      Sorry, late to the party. (^_^)
      Radio controls as set up in a frame control return a numeric value to the frame. This why your 1,2,3,4 worked in the query.

      Comment

      Working...