473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Access: DCount Code help Part 2

Please note: Action Log (table name), Action Type(dropdown options w/ in Action Log), Complete (Criteria),and Action Date (Date time field w/in Action Log).

As a Field Name I place this in my Query:

Expand|Select|Wrap|Line Numbers
  1. Expr1: DCount("*","Action Log","[Action Type] <> 'Complete' AND [Action Date] IS NOT NULL")
And Expression in the Total type

Now I need to make this Expr1 only work for the Action type Delayed.

Example: Total 17
Delayed = 5
Dropped = 1
New = 7
Complete = 4

What I get w/ the Expr1 is 13 for all. What I need is

Example: Total 17
Delayed = 1 (this should be 5(Delayed)-4 (Complete))
Dropped = 1
New = 7
Complete = 4

This will end up in a report. I posted that question as well. So if you need info on the end game you may wish to read that one too. Thank you!
Sep 29 '10 #1

✓ answered by MMcCarthy

Sorry my fault, try this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT "Total" AS [Action Type], Count([Action Date]) AS [CountOfAction Date] 
  2. FROM [Action Log] 
  3. GROUP BY "Total" 
  4. UNION  
  5. SELECT [Action Type],  
  6. IIf([Action Type]="Delayed",Count([Action Date])-DCount("[Action Date]","Action Log","[Action Type]='Complete'"),Count([Action Date])) AS [CountOfAction Date] 
  7. FROM [Action Log] 
  8. GROUP BY [Action Type];

13 1745
MMcCarthy
14,534 Expert Mod 8TB
Susan

Can you change the view of the query to SQL and post the full SQL code for this query. Then explain which results are not showing correctly.

At the moment I'm confused.

Mary
Sep 29 '10 #2
SQL:
Expand|Select|Wrap|Line Numbers
  1. SELECT [tblAction Log].[Action Type], Count([tblAction Log].[Action Date]) AS [CountOfAction Date]
  2. FROM [tblAction Log]
  3. GROUP BY [tblAction Log].[Action Type];
Sep 29 '10 #3
MMcCarthy
14,534 Expert Mod 8TB
Susan

This doesn't tell me what's wrong. This query will give you a count of the different dates for each action type. What do you want it to do?

Mary
Sep 30 '10 #4
Sorry This is the SQL:

Expand|Select|Wrap|Line Numbers
  1. SELECT [Action Log].[Action Type], Count([Action Log].[Action Date]) AS [CountOfAction Date], DCount("*","Action Log","[Action Type] <> 'Complete' AND [Action Date] IS NOT NULL") AS Expr1
  2. FROM [Action Log]
  3. GROUP BY [Action Log].[Action Type];
What I get is 13. 17 (total)- 4 (Complete)= 13
I need it to only subtract Complete from the Delayed total.

Should look like this

Example: Total 17
Delayed = 1 (this should be 5(Delayed)-4 (Complete))
Dropped = 1
New = 7
Complete = 4
Sep 30 '10 #5
MMcCarthy
14,534 Expert Mod 8TB
OK try this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT "Total", Count([Action Date]) AS [CountOfAction Date]
  2. FROM [Action Log]
  3. GROUP BY [Action Type];
  4. UNION 
  5. SELECT [Action Type], 
  6. IIf([Action Type]="Delayed",Count([Action Date])-DCount("[Action Date]","Action Log","[Action Type]='Complete'"),Count([Action Date]) AS [CountOfAction Date]
  7. FROM [Action Log]
  8. GROUP BY [Action Type];
  9.  
Sep 30 '10 #6
No didn't work. "Syntax error in union query"
Oct 6 '10 #7
MMcCarthy
14,534 Expert Mod 8TB
Sorry I had an extra semi colon in the code.

Expand|Select|Wrap|Line Numbers
  1. SELECT "Total", Count([Action Date]) AS [CountOfAction Date]
  2. FROM [Action Log]
  3. GROUP BY [Action Type]
  4. UNION 
  5. SELECT [Action Type], 
  6. IIf([Action Type]="Delayed",Count([Action Date])-DCount("[Action Date]","Action Log","[Action Type]='Complete'"),Count([Action Date]) AS [CountOfAction Date]
  7. FROM [Action Log]
  8. GROUP BY [Action Type];
Oct 6 '10 #8
it is also missing a " ) " some where here
Expand|Select|Wrap|Line Numbers
  1. IIf([Action Type]="Delayed",Count([Action Date])-DCount("[Action Date]","Action Log","[Action Type]='Complete'"),Count([Action Date]) AS [CountOfAction Date] 
  2. FROM [Action Log] 
  3. GROUP BY [Action Type];
and my self not great at reading this kind of stuff.... not sure where, but I will try some places I think it goes and let you know.
Oct 7 '10 #9
ok I found where it goes.
Expand|Select|Wrap|Line Numbers
  1. SELECT "Total", Count([Action Date]) AS [CountOfAction Date] 
  2. FROM [Action Log] 
  3. GROUP BY [Action Type] 
  4. UNION  
  5. SELECT [Action Type],  
  6. IIf([Action Type]="Delayed",Count([Action Date])-DCount("[Action Date]","Action Log","[Action Type]='Complete'"),Count([Action Date])) AS [CountOfAction Date] 
  7. FROM [Action Log] 
  8. GROUP BY [Action Type]; 

This is what I get: Why do I have all the " at the end "Toatl"?

Expr1000 CountOfAction Date
0
Delayed 0
Discontinued 1
E-Qip Initiation 3
New Security Packet 9
Other 2
Complete 6
Total 0
Total 1
Total 2
Total 3
Total 6
Total 9
Oct 7 '10 #10
MMcCarthy
14,534 Expert Mod 8TB
Sorry my fault, try this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT "Total" AS [Action Type], Count([Action Date]) AS [CountOfAction Date] 
  2. FROM [Action Log] 
  3. GROUP BY "Total" 
  4. UNION  
  5. SELECT [Action Type],  
  6. IIf([Action Type]="Delayed",Count([Action Date])-DCount("[Action Date]","Action Log","[Action Type]='Complete'"),Count([Action Date])) AS [CountOfAction Date] 
  7. FROM [Action Log] 
  8. GROUP BY [Action Type];
Oct 8 '10 #11
NeoPa
32,556 Expert Mod 16PB
Try this :
Expand|Select|Wrap|Line Numbers
  1. SELECT   'Total' AS [Action Type]
  2.        , Count([Action Date]) AS [CountOfAction Date]
  3. FROM     [Action Log]
  4. UNION ALL
  5. SELECT   [Action Type]
  6.        , Count(*) - 
  7.          IIf([Action Type] = 'Delayed'
  8.            , DCount('[Action Date]'
  9.                   , '[Action Log]'
  10.                   , '[Action Type] = ''Complete''')
  11.            , 0)
  12. FROM     [Action Log]
  13. GROUP BY [Action Type]
I notice the total in your example is still 17 even though the items displayed that make up the total are missing the equivalent of the Complete items. Should you wish this to be reflected in your total (13 rather than 17 in your example) then add the following line after line #3 :
Expand|Select|Wrap|Line Numbers
  1. WHERE    ([Action Type] <> 'Complete')
Oct 9 '10 #12
Both McCarty and NeoPA work the same the only diff. is
WHERE ([Action Type] <> 'Complete') and how it shows.
Oct 12 '10 #13
Thank you both
Oct 12 '10 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sergio del Amo | last post by:
Hi, I implemented a Web-Site based in remote scripting with hidden frames. I am using Javascript to provide dynamic functionality. In the machine's local server works perfectly but when i uploaded...
0
by: ImraneA | last post by:
Hi there I had pleasure of upsizing Access v97 db to Access v2K/SQL 2K. Wish to provide some knowledge gained back to community - hopefully help others. 1.Using Upsizing wizard - will...
13
by: BigDaDDY | last post by:
Um yeah....In case you haven't figured it out, Microsoft sucks. I'm going to be kicked back in my chair eating popcorn and watching football 10 years from now, while all you clowns are scrambling...
1
by: Mike Ridley | last post by:
I have just inherited an Access Booking Application. Works fine, including some quite complex code that calculates an availability table from dates input by the user. I have produced a simple...
26
by: jamesbeswick | last post by:
I've been using Access since version 97 and I've migrated to 2003. I've noticed a substantial number of strange ActiveX/OLE and code corruption problems when writing databases. The only solution...
2
by: Stephen E. Weber | last post by:
I have an access database with an "item number" and a filespec for a JPG with the image for the item and a filespec for a HTM document with the description and specifications. I use a List Box and...
4
by: Ben | last post by:
Hi, i have some problem to access from code-behind a label nested into a CreateWizard control. I use a html-table for align purpose only. I try to change the text property of the label with...
5
by: jasperz01 | last post by:
Hi, Is it possible using Office Automation to freeze panes in Excel from Access VBA code? I've been trying some things but can't get it right... Jasper
0
by: JFKJr | last post by:
I have an excel file, which has columns C and D grouped together, I am trying to delete blank columns and rows from the excel file, ungroup the columns and import the file to MS Access using Access...
8
by: SusanK4305 | last post by:
This is what I have: =DCount(-"","Action Log"," = 'Complete'") I placed it in a criteria field in a Query. File Name reads "Action Date" I need to count how many Records have an Action Date if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.