469,607 Members | 2,154 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,607 developers. It's quick & easy.

open different forms based on the results of a count query

lwwhite
16
When a user clicks OK on form "SelectDefaults," I want to open form "Welcome" if the results of query "qry_todo_overdue" = 0 or form "OverdueToDo" if the results >= 1. First, I assume that I need to run the query in "SelectDefault's" OnOpen event, right? But having done that, I'm not sure how to incorporate the query-checking into an If...Then statement on the OK button's OnClick event.

Here is the query's SQL:

SELECT Count(*) AS Expr1
FROM tbl_tasklist
WHERE (((tbl_tasklist.ptsk_duedate)<Date()) AND ((tbl_tasklist.ptsk_assigned)=[Forms]![SelectDefaults]![User]));

On a related note, and you may prefer this to be a separate thread, I want to show or hide a button on a form ("iScope") based on the results of a query ("qry_todos_for_issue"). Here is that SQL:

SELECT Count(*) AS Expr1
FROM tbl_tasklist
WHERE (((tbl_tasklist.ptsk_issue)=[Forms]![iScope]![issue]));

Again, I assume the first step is to run "qry_todos_for_issue" in "iScope's" OnOpen event. I guess I also need to run it in the OnCurrent event for when users open a different record while the form is still open? And then, I also don't know how to incorporate the query-checking into the button's code to determine the Visible property.

If there is an altogether better way to accomplish either of these things other than with a query, I would love to know. Any help is much appreciated, as always!

Leigh
Apr 27 '07 #1
1 1646
Rabbit
12,516 Expert Mod 8TB
You can retrieve the count in many ways. The easiest is to just use DLookup to get the value.
Expand|Select|Wrap|Line Numbers
  1. If DLookup("Expr1", "QueryName") = 0 Then
  2.      ...
  3. Else
  4.      ...
  5. End If
Apr 27 '07 #2

Post your reply

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

Similar topics

1 post views Thread by Rich | last post: by
46 posts views Thread by Steve | last post: by
6 posts views Thread by Keith Smith | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.