Solved

Proper Dcount Syntax

Posted on 2013-11-13
2
336 Views
Last Modified: 2013-11-13
I have the following rowsource in a list box pulling data to display... which is working:

SELECT Count(*) FROM Tpatient WHERE (((Tpatient.RecallNumber)=0) And ((Date()-TPatient!LastApmnt)>(TPatient!RecallFreq*30)) And ((TPatient!RecallActive)=-1)) Or (((Date()-TPatient!RecallNotice)>30) And ((Tpatient.RecallFreq)<12) And ((Tpatient.RecallNumber)<4) And ((Date()-TPatient!LastApmnt)>360) And ((TPatient!RecallActive)=-1)) Or (((Date()-TPatient!RecallNotice)>30) And ((Tpatient.RecallFreq)>=12) And ((Tpatient.RecallNumber)=1) And ((TPatient!RecallActive)=-1));

SELECT Count(*) FROM TPatient WHERE (((TPatient.FirstVLetter)=0) AND ((TPatient.RecallActive)=-1) AND ((TPatient.Zip) Is Not Null));

I would like to change each of these to for use in VBA with a DCount to obtain their value.  I am not able to get the syntax correct.

Is this possible and if so what should the proper syntax be for DCount?
0
Comment
Question by:thandel
2 Comments
 
LVL 24

Accepted Solution

by:
chaau earned 500 total points
ID: 39646964
Syntax for the first case:
DCount("*", "Tpatient" , "(((Tpatient.RecallNumber)=0) And ((Date()-TPatient!LastApmnt)>(TPatient!RecallFreq*30)) And ((TPatient!RecallActive)=-1)) Or (((Date()-TPatient!RecallNotice)>30) And ((Tpatient.RecallFreq)<12) And ((Tpatient.RecallNumber)<4) And ((Date()-TPatient!LastApmnt)>360) And ((TPatient!RecallActive)=-1)) Or (((Date()-TPatient!RecallNotice)>30) And ((Tpatient.RecallFreq)>=12) And ((Tpatient.RecallNumber)=1) And ((TPatient!RecallActive)=-1))")

Open in new window


Syntax for the second case:
DCount("*", "TPatient", "(((TPatient.FirstVLetter)=0) AND ((TPatient.RecallActive)=-1) AND ((TPatient.Zip) Is Not Null))")

Open in new window

0
 

Author Closing Comment

by:thandel
ID: 39646973
OK that was pretty straight, not sure why it wasn't working for me... I think I was missing a quote.  Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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 …

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now