Query Cond - Numberic Vs. Text

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smrkeyan316
    New Member
    • Sep 2008
    • 5

    Query Cond - Numberic Vs. Text

    Hello,

    Please help me to solve this.

    I have a query which calculates sum of pages.

    Total Pages: Sum([TASK ID 37])

    I have a option button in my FORM wich has two conditions
    a) > 11 pages - option button 1
    b) <=11 pages - option button 2

    in my query i want to display condition 1 if option 1 is selected and vice versa.

    below is the query i am trying.

    SELECT Query_Tbl_Audit _Data_Filter.Em ployeeID AS [Oper #], Sum(nz([TASK ID 37])) AS [Total Pages]
    FROM Query_Tbl_Audit _Data_Filter
    GROUP BY Query_Tbl_Audit _Data_Filter.Em ployeeID
    HAVING (((Sum(nz([TASK ID 37])))=IIf([Forms]![Home]![SuffCond]=1,(Sum(nz([TASK ID 37])))>11,(Sum(nz([TASK ID 37])))<=11)));

    Regards,
    Karthikeyan S
  • DonRayner
    Recognized Expert Contributor
    • Sep 2008
    • 489

    #2
    Use the setting of your option button to set a global variable. Use that variable in a function to set the value of the function and then use the function as the condition in your query.

    EG:
    The module for your form would contain
    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub MyOptionButton_Change()
    On error GoTo ErrPoint
    
        If Me.MyOption.value = True then
            MyPublicVar = True
        Else
           MyPublicVar = False
        End If
    
    ExitPoint:
        Exit Sub
    ErrPoint:
        ' Error traping code goes here
        Resume ExitPoint
    End Sub

    Then Create a module MyModule
    It would look like this

    Code:
    Option Compare Database
    Option Explicit
    
    Public MyVar
    
    Public Function MyFunction() as string
        MyFunction = MyVar
    End Function
    Finally add the MyFunction() as the criteria in your query.....
    Hope this helps

    Comment

    Working...