Display query results on form????

mvpejp

Registered User.
Local time
Today, 02:48
Joined
Oct 23, 2002
Messages
23
Really need help please.

I have made a real simple query based on Account Type Table. There are three Account Types (SAle, No Sale, and Other). The query has two columns one is Accounttypeid with Group By and the second column is Accounttypeid COUNT. When I view the results I get the following output:

Sale - 15
No Sale - 10
Other - 25

How can I display the results of this query on an unbound form? I can't seem to figure it out.

For instance on my unbound form I want to put a label that says "total sales" and then in the text box display the result of the query above which in this example would be 15.

Please help thank You in advance

MVPEJP
 
You want to have your form bound to your query if you are wanting to display the results. If you absolutly don't want to have the form bound to the query, then use the DLookup function.

=DLookup("Sales","MyQuery")
 
You can use the query as the rowsource for a listbox.

To use DLookup(), you would need to use three DLookup()'s. You would need to supply criteria and run one DLookup() for each value that you want to return.

Because DLookup() is a function, it can only return a SINGLE value. If the criteria does not limit the possible values to a SINGLE row, Access chooses which of the multiple values it did find to return. The help entry tells you how Access chooses which SINGLE value to return.
 
Can I get this to refresh, though?

Hi, all.

I was trying to do just this very thing! So kudos to the forum and the search tool.

I have used the DLookup function to do exactly this - I return a value to the form (in this case the number of calls) in a text box, based on input from combo boxes on the form, for user, date, and call type.

When the form loads (blank), and I select the three values, my value for the number of calls shows up properly, but if I change any of the three values (name, date or call type), the value of my "Number" does not change unless I reload the form. Can I get the DLookup to refresh (rerun the query?) when I change the values in my form combo boxes?

Thanks in advance,

databasedonr
 
Add a button to the form to requery the control with the DLookup().
 

Users who are viewing this thread

Back
Top Bottom