MS Access Forum / Queries / January 2006
Queries are driving me nuts!
|
|
Thread rating:  |
Frogfreak55 - 28 Jan 2006 22:05 GMT I've created a query and am getting the results I want. Unfortunately one of the results I want brings back and empty response. Is there a way, that if the query is negative to have it show something I type i.e. "Has not yet taught"? I know, although I haven't tried, that you can do it with one field using the experssion builder, but can you do it for the whole query?
Duane Hookom - 29 Jan 2006 04:56 GMT "empty response" "query is negative" don't suggest what's going on with your query. Can you provide an example of your query datasheet and how you would like to display it? Is this the record source for a form or report?
 Signature Duane Hookom MS Access MVP --
> I've created a query and am getting the results I want. Unfortunately one > of [quoted text clipped - 4 lines] > field > using the experssion builder, but can you do it for the whole query? Frogfreak55 - 29 Jan 2006 16:36 GMT Duane, I'm not sure I know which part is the datasheet, is that the results of the query or the design? This is going to be a record source for a report. To try and make it easier for you to help me, let me give you the background. I'm an instructor and we have to keep track of the time and classes we teach. Up until a week ago, when I found out about parameter queries I was going to build around 30 queries for each instructor to fill in the 4 reports I want to see. When I changed the queries to parameter quires, the reports were still working fine as long as I used my name. I had previously put information for my name in everything. When I tried to use someone else's name the report was totally blank. I then ran each query separately to see if I messed up somewhere. What I found was that some instructors have not taught every lesson yet. So in essence the query is working. However, nothing else on the report will show because there is no data in that one query. The report ends up with about 10 queries on it. What I would like it to do, is if it comes back with no information meeting the requirement, just to display "has not yet taught". I can get it to show information however, I would have to make sure there is an input for every entry for every person’s name. For instance, I have the columns on my query, all from my main table. Names, Time, and Block 1. I have a parameter set for names, I have the time block set to sum, and Block 1 I only want to see 2 (it's tied to another table with all our lessons on it). If I search for my name the query comes back with my name, the name of the lesson and the total time I've taught it. If I search for another name, who has not yet taught it, the query is blank. At this point I would still like it to show the name, name of the lesson and instead of the time, tell me the person hasn't taught it yet. I did try to do it by building an expression but, if you can't tell I have no experience with expression building yet. I am starting to think there might be a totally different way to get the info I want but, have not yet been able to figure out what it is. I hope this makes some sense to you. Thanks again for helping.
Dave
> "empty response" "query is negative" don't suggest what's going on with your > query. Can you provide an example of your query datasheet and how you would [quoted text clipped - 8 lines] > > field > > using the experssion builder, but can you do it for the whole query? Duane Hookom - 29 Jan 2006 20:54 GMT I don't have a clue what your table structure are and how your queries are created. You mention instructors, classes and blocks but I see only "Names, Time, and Block 1" as potential field names.
A couple other hints: 1) feel free to break your replies into paragraphs and use some indenting or whatever 2) "Names" would not make a good field name. It suggests multiple values in a single field and every object has a name. If this is an actual field that store Instructor names, consider using "InstName" or "InstFirstName" and "InstLastname" 3) look up Help on LEFT an RIGHT JOINS. These can show all the records from one table and values or nulls from the other table 4) Parameter queries are a phase that you go through. As you get more experience you will find that using controls on forms for criteria is much more professional.
 Signature Duane Hookom MS Access MVP --
> Duane, > I'm not sure I know which part is the datasheet, is that the results of [quoted text clipped - 61 lines] >> > field >> > using the experssion builder, but can you do it for the whole query? Frogfreak55 - 29 Jan 2006 22:08 GMT Thanks for trying to help me. I know my expierence level makes it a little harder then most. I'm not sure how to explain my problem or maybe ask a different question without long explainations. I did write something in word with some screen shots but, I can't past the pictures here. Can I send it direct to your e-mail address?
> I don't have a clue what your table structure are and how your queries are > created. You mention instructors, classes and blocks but I see only "Names, [quoted text clipped - 78 lines] > >> > field > >> > using the experssion builder, but can you do it for the whole query? Duane Hookom - 29 Jan 2006 22:47 GMT Please don't email me directly. If we get too stuck, I might consider this later.
Describe your table structures and data. A few sample records are very helpful. Then tell us how you want your queries and/or reports to appear.
 Signature Duane Hookom MS Access MVP --
> Thanks for trying to help me. I know my expierence level makes it a > little [quoted text clipped - 110 lines] >> >> > field >> >> > using the experssion builder, but can you do it for the whole query? Frogfreak55 - 30 Jan 2006 02:46 GMT I hope this helps. . . .
Glad you are still helping. I know my field names aren’t the best but, this was just a test database to see if I could get everything to work, then I was going to build the real database. My table is set up with the following fields: Names, Block 1, Block 2, Block 3, Training Managers Course, Scenario Training, Homework Review, Lesson Plan block 1, Lesson Plan block 2, Lesson Plan block 3, Lesson Plan training managers course, Time, Date, Test Review, Test Administration, and Counseling. All of the fields except time and date are linked to tables of the same name to use as a lookup or pull down menu. I thought this best in case we make any changes to the lessons we teach or add instructors. I then built a form to use for inputs. I wanted to build an overview report first. To show the total amount of time an instructor has taught. So it will just sum up different lessons and merge them into larger groups. I built my first query to sum up all the time of classroom instruction which is all of Block 1, Block 2, Block 3 and Training Managers Course from my table. The query was designed with the following fields from my main table: Names, Time, Block 1, Block 2, Block 3 and Training Managers Course.
Field: Names Time Block 1 Block 2 Block 3 Training Managers Table: Main Table “””” “””” “””” “””” “””” Total: Group By Sum Where Where Where Where Criteria: [Who] Between 1 And 9 Or: Between 1 And 11 Or: Between 1 And 4 Or: Between 1 And 10
This Query gives me exactly what I was looking for. I then built similar queries to total other fields I wanted on my overview report: Scenario Totals, Homework Review Totals, Lesson Plan Totals, Test Review Total, Test Administration Total, and Counseling totals. To finish of my overview report I created 3 additional queries to sum the totals of the Classroom instruction totals, Scenario totals, and Homework Review Totals into one field. Lesson Plan totals, into another field. Then finally to sum up Test Review Total, Test Administration totals, and Counseling totals into a 3rd field. So my overview report looks something like this
Classroom Instruction ______199.4 Scenario _________________23.5 Classroom Total __225.15 Homework Review_________2.25
Lesson Plan_______________19.25 Lesson Plan total__19.25
Test Review ______________4.75 Test Administration_________5.75 Administration Total__11.75 Counseling________________1.25
Now, what I am trying to do is to build separate reports for each “Total” to break down more into each area that makes up the total. List out the lesson and the total for each lesson. So, a report for Classroom Total would look like this.
Block 1
C2 Terminology/C2 Systems ___________________2.5 AMC Mission_______________________________4.50 AMC Stucture_______________________________6.50
Block 2
Mission Numbers____________________________4.60 Purpose Codes______________________________3.75 Ground Times______________________________6.00
Block 3 GDSS 2___________________________________22.15 M3C_____________________________________10.50
Training Managers Course
Problem Solving___________________________4.5 Cert/Decert________________________________2.0
To start this report I thought the easiest way would be to create a query to total the amount of time for each lesson. Then just label it on my report. Then put all the queries on a single report. For instance the query for the total for block 1, lesson 2 (AMC Mission) Looks like this
Field: Names Block 1 Time Table: Main Table Main Table Main Table Total: Group By Group By Sum Criteria: [Who] 2
This is where it all went downhill for me. If I run this query using my name (Dave) it comes back with Names Block 1 SumOfTime Dave AMC Mission 5
This is what I wanted. However, if I run the query with the name Kevin, it comes back with nothing. Looks like this.
Names Block 1 SumOfTime
The query works, Kevin has not taught Block 1, lesson 2 (AMC Mission) yet. If this query is run on my report though, none of the queries will return information even if he has taught a lesson meeting their criteria. What I would like to do, if possible, is that if a query runs and nothing matches the criteria, to show up on the report and look like this:
Block 1
C2 Terminology/C2 Systems ___________________2.5 AMC Mission_______________________________Has not yet taught. AMC Stucture_______________________________6.50
Block 2
Mission Numbers____________________________4.60 Purpose Codes______________________________3.75 Ground Times______________________________6.00
Block 3 GDSS 2___________________________________22.15 M3C_____________________________________10.50
Training Managers Course
Problem Solving___________________________4.5 Cert/Decert________________________________2.0
I’m sure once I build my experience level that there will probably be a much easier way to do all of this however, this is all I know at the moment. Thanks again, I can’t say it enough
Dave
> Please don't email me directly. If we get too stuck, I might consider this > later. [quoted text clipped - 116 lines] > >> >> > field > >> >> > using the experssion builder, but can you do it for the whole query? Duane Hookom - 31 Jan 2006 04:54 GMT I would not put any more effort into a system that is not normalized. Apparently you are storing time spent by instructors doing various tasks for various classes/lessons. I would create a table like:
InstructorID BlockNumber TimeSpent DateWorked ActivityCode
I might be wrong with this guess at your base requirements but I hope you can figure out the normalization. Once your tables are normalized, queries and reports are much easier.
BTW: Date and Time are function names and shouldn't be used as field names.
 Signature Duane Hookom MS Access MVP --
>I hope this helps. . . . > [quoted text clipped - 295 lines] >> >> >> > using the experssion builder, but can you do it for the whole >> >> >> > query?
|
|
|