Re: Count

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



=IIF(DCount("*", "qryJobs")=1, DLookup("ProjNo","qryJobs"), "M")

--
Steve Clark, Access MVP
http://www.fmsinc.com/consulting
*FREE* Access Tips: http://www.fmsinc.com/free/tips.html

"Ivor Williams" <ivor@xxxxxxxxxxxxxx> wrote in message
news:jA6Hf.475986$2k.25741@xxxxxxxxxxx
I've created a query called qryJobs. Following is the SQL view of this
query:

SELECT tblMaterial.POID, tblMaterial.ProjNo, Count(tblMaterial.ProjNo) AS
Jobs
FROM tblMaterial
GROUP BY tblMaterial.POID, tblMaterial.ProjNo
HAVING (((tblMaterial.POID)=[FormsPO]![txtPOID]));

I've created a second query called qryJobCount which uses as a record
source the qryJobs query. Following is the SQL view of the qryJobCount
query:

SELECT qryJobs.POID, qryJobs.ProjNo, Count(qryJobs.Jobs) AS CountOfJobs,
IIf([Jobs]=1,[ProjNo],"M") AS Suffix
FROM qryJobs
GROUP BY qryJobs.POID, qryJobs.ProjNo, IIf([Jobs]=1,[ProjNo],"M");

I've created a report based on the qryJobCount query. On the report is a
text box. If there is only one record in the qryJobCount query, I want the
value in the qryJobs.ProjNo to be displayed in the text box. If there is
more than one record in the qryJobCount query, I want the text box to
display "M".

Where I run into a problem is when there is only one record in the
tblMaterial table with the ProjNo field. In that situation, the
qryJobCount query returns more than one record. All I want is one record
which will display either a ProjNo value or "M".

How can I resolve this problem?

Ivor





.



Relevant Pages

  • Re: Obtaining a filter from a form
    ... using the query grid. ... Access MVP 2002-2005, 2007-2008 ... After a user has implemented various filters on various fields on ... that the user has chosen to display. ...
    (microsoft.public.access.queries)
  • Re: Form based on many to many relationship
    ... <MS ACCESS MVP> ... the other fields I need to display - I've created a combo box using the ... event from the query and then use the 'Find' button to go to the one I ... I then create a query to show contacts in the first column and the ...
    (microsoft.public.access.forms)
  • Re: Date Range
    ... Vanderghast, Access MVP ... > entering each month and year that I want to display in my ... > from the query. ...
    (microsoft.public.access.queries)
  • Re: Query Shows Value Incorrectly from a Join
    ... and why you want to display the results the way you describe? ... <MS ACCESS MVP> ... When I query to show the data from both tables, ... > value from Table 2 once and the values from Table 1 twice? ...
    (microsoft.public.access.queries)
  • Re: date expression question
    ... So, in a query ... John Spencer ... Access MVP 2002-2005, 2007 ... to display this month, but I do want to display next month and beyond. ...
    (microsoft.public.access.queries)