Count number of rows depending on criteria

109bow

Registered User.
Local time
Today, 18:57
Joined
Oct 24, 2007
Messages
138
Morning guys,

With plog's help my previous question has been resolved and I have been able to create the chart I was hoping for.
I am now hoping, with some help, to create a table in form "forcast_planning2_form", that gives the number of rows in query "forcast_planning2" that are within a given range in field "wkstonextturn" and where "cartype" is either "Motor" or "Trailer". I have added some text boxes to the form to try and illustrate what I'm aiming for.
Many thanks in advance.
 

Attachments

  • chart in form.jpg
    chart in form.jpg
    395.9 KB · Views: 29
  • query.jpg
    query.jpg
    536.9 KB · Views: 27
The trick will be the criteria clause, whether you do this as a query or as a DCount() (as suggested by Gasman).

Your usage of
I am now hoping, with some help, to create a table in form
seems a bit awkward. I am not sure what you meant by that. You don't normally create tables in a form. If this is a language issue, I understand, but normally you have to have a table first, THEN you create a form.

Let's attack your query.

within a given range in field "wkstonextturn" and where "cartype" is either "Motor" or "Trailer".

The field wkstonextturn appears to be either SINGLE or DOUBLE (but it could be scaled integer, I can't tell.) Let's say that your field is at least SINGLE and your desired range is from 20 to 40 (just for discussion.) The criteria clause would be:
Code:
( wkstonextturn BETWEEN 20 AND 40  ) AND ( ( cartype = "Motor" ) OR ( cartype = "Trailer" ) )

I added parentheses for clarity, and also because when you have mixed AND/OR criteria expressions you DO have to be a bit careful. The criteria clause would either be the third argument in a DCount() or would follow the word WHERE in a more formal query.
 
Domain functions should always be your last option. If you are building a graph, the wizard should give you filtering and summarization options.
 
The_Doc_Man, many thanks for taking the time to reply.
Its taken me a while to get my head round this, but still not there. I have created some formulas based on your formula and created another query to get the results I need query3. I'm struggling to create a line graph based on the results in query3, where x-axis would be wkstonextturn, but grouped is the column headers in query3, and the y-axis the number resulting from the formula in each column. I need to lines in the graph, one for Motor and one for Trailer, from cartype.
Apologises for the terminology I have used, I'm still very much a novice.
Any assistance in achieving my intended graph would be very much appreciated
 

Attachments

  • query1.jpg
    query1.jpg
    536.7 KB · Views: 9
  • query3 design.jpg
    query3 design.jpg
    344.5 KB · Views: 9
  • query3.jpg
    query3.jpg
    364.4 KB · Views: 8

Users who are viewing this thread

Back
Top Bottom