Solved

# If Null and Dcount

Posted on 2013-06-29
Medium Priority
422 Views
In the below, if Dcount is >0  then the return will either be "Yes" or "-".  I want to add a criteria if Dcount is Null then return " " (a blank) to show me that there are no records.  I think I need to add another criteria?  Possibly Switch?

ExpctDepart: IIf(DCount("*","qryDepartures_3","ProjectID= " & [Projects.ID])>0,"Yes","-")

qryDepartures_3:
SELECT tblDepartures.ProjectID, tblDepartures.DraftedDocYN, tblDepartures.ConfirmedDepartureYN
FROM tblDepartures
WHERE (((tblDepartures.ConfirmedDepartureYN) Is Null Or (tblDepartures.ConfirmedDepartureYN)=True))
GROUP BY tblDepartures.ProjectID, tblDepartures.DraftedDocYN, tblDepartures.ConfirmedDepartureYN
HAVING (((tblDepartures.DraftedDocYN)="Yes" Or (tblDepartures.DraftedDocYN) Is Null));

thank you
0
Question by:pdvsa
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3
• 2

LVL 48

Accepted Solution

Dale Fye earned 1000 total points
ID: 39286724
DCOUNT will never be NULL.  It will always return a numeric value.
0

Author Comment

ID: 39286731
Hi fyed, maybe i could use =0 somehow?
0

LVL 51

Expert Comment

ID: 39286741
You probably think of something like this:

ExpctDepart: Format(DSum("Abs([DraftedDocYN])","qryDepartures_3","ProjectID= " & [Projects.ID]), "\Y\e\s;;\-;")

/gustav
0

Author Comment

ID: 39286779
Cactus.... Very funky looking.... Interesting.  I will test when back at computer.  Thank you
0

Author Comment

ID: 39286901
Cactus,

I get a "data type mismatch in criteria or expression" error when I run from qry design builder.  When I paste it, it changes it a bit to the below.

ExpctDepart: Format(DSum("Abs([DraftedDocYN])","qryDepartures_3","ProjectID= " & [Projects.ID]),"""Yes"";;-")
^^^^^^^^

Not sure if DraftedDocYN would be the problem.  It is not a true YN field...I have since then modified it to a combo value list with values of "Yes";"No";"previously issued";"Don’t Need it"

let me know what is next...
0

LVL 51

Assisted Solution

Gustav Brock earned 1000 total points
ID: 39287161
If DraftedDocYN is not a Boolean field (WHO could know), you will, of course, have to adjust.

Try starting with a Boolean field and:

ExpctDepart: DSum("Abs([DraftedDocYN])","qryDepartures_3","ProjectID= " & [Projects.ID] & "")

The apply the format.

/gustav
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
###### Suggested Courses
Course of the Month10 days, 12 hours left to enroll