Topic awaiting preservation: Access question (Page 1 of 1) |
|
---|---|
Paranoid (IV) Mad Scientist From: Right-dead center |
posted 01-06-2005 20:49
I've set up a database to keep track of the different cities, states, and pharmacies that I have traveled to in the past three years with my job. I've got the database all set up and now I'm creating some different reports and queries for different things that I'm interested in. |
Paranoid (IV) Inmate From: France |
posted 01-06-2005 20:56 |
Paranoid (IV) Mad Scientist From: Right-dead center |
posted 01-06-2005 21:37
Here's a screenshot. It's a pretty small DB right now: |
Paranoid (IV) Inmate From: France |
posted 01-06-2005 21:48
Ok, so to get the count of states, just do : code: SELECT COUNT( DISTINCT State ) FROM `Trips` Now to get the number of times you've been in state, do : code: SELECT State, count( State ) FROM `Trips` GROUP BY State Sorry I've never used Access so the queries might need some adjustements. |
Paranoid (IV) Mad Scientist From: Right-dead center |
posted 01-07-2005 18:03
Thanks for the SQL but my question has more to do with where should I use that SQL? In a report? Is there a way to add that to a query? |
Paranoid (IV) Inmate From: France |
posted 01-07-2005 18:13 |
Maniac (V) Mad Scientist From: :morF |
posted 01-07-2005 18:14
You can create a custom field on a report and use that SQL as it's data source |
Paranoid (IV) Mad Scientist From: Right-dead center |
posted 01-07-2005 18:20
So when I create a textbox on the report, would the SQL go into the Control Source for that text box? |
Maniac (V) Mad Scientist From: :morF |
posted 01-07-2005 22:44
I believe so, yes... you can even have the query feed it's control data (say, the city or state you want a count of) from another field, and if that field is blank it will prompt you for it when you generate the report |