By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,602 Members | 1,661 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,602 IT Pros & Developers. It's quick & easy.

Query Cond - Numberic Vs. Text

P: 5

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.EmployeeID AS [Oper #], Sum(nz([TASK ID 37])) AS [Total Pages]
FROM Query_Tbl_Audit_Data_Filter
GROUP BY Query_Tbl_Audit_Data_Filter.EmployeeID
HAVING (((Sum(nz([TASK ID 37])))=IIf([Forms]![Home]![SuffCond]=1,(Sum(nz([TASK ID 37])))>11,(Sum(nz([TASK ID 37])))<=11)));

Karthikeyan S
Sep 20 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 489
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.

The module for your form would contain
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  4. Private Sub MyOptionButton_Change()
  5. On error GoTo ErrPoint
  7.     If Me.MyOption.value = True then
  8.         MyPublicVar = True
  9.     Else
  10.        MyPublicVar = False
  11.     End If
  13. ExitPoint:
  14.     Exit Sub
  15. ErrPoint:
  16.     ' Error traping code goes here
  17.     Resume ExitPoint
  18. End Sub

Then Create a module MyModule
It would look like this

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  4. Public MyVar
  6. Public Function MyFunction() as string
  7.     MyFunction = MyVar
  8. End Function
Finally add the MyFunction() as the criteria in your query.....
Hope this helps
Sep 21 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.