Solved

Proper Dcount Syntax

Posted on 2013-11-13
2
337 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

832 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