Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 24th, 2004, 09:55 AM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Activity schedule

Hi all,

Please advice me on the following issue:

I have a table with activities by month, something like this:

ID Month Year Type Description
--------------------------------------------------
01 Jan 2005 Campign Summer discount
02 Jan 2005 Adverts CAD/CAM Magazine
03 Jan 2005 Adverts Machinery
04 Feb 2005 Seminar Hotel Beurs
and so on....


I've created a cross tab query, that should display all activity types (row heading), all months (colmn heading) by a given year.

The SQL code look like this:

Code:
TRANSFORM Max(T_GTMActivities.ActivityDescription) AS MaxOfActivityDescription
SELECT T_GTMActivities.ActivityType
FROM T_GTMActivities
WHERE (((T_GTMActivities.ActivityYear)=[Forms]![F_Reseller_GTMActivitiesPlanningSelection]![cboSalesYear]) AND ((T_GTMActivities.Reseller)=[Forms]![F_Reseller_GTMActivitiesPlanningSelection]![cboReseller]))
GROUP BY T_GTMActivities.ActivityType
PIVOT T_GTMActivities.ActivityMonth In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
As you can see in my table example above, there are 2 adverts in Jan. But my query only shows one of them. Not both. If did some experiments with the options Max, Min, First, Last, Count but couldn't find the solution.

I want the output like this

Type Jan Feb Mar etc.
-------------------------------------------------
Campign Summer discount
Adverts CAD/CAM Magazine
Adverts Machinery
Seminar Hotel Beurs



Could anyone help?

Reply With Quote
  #2 (permalink)  
Old November 24th, 2004, 10:30 AM
Authorized User
 
Join Date: May 2004
Location: Bucharest, , Romania.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It appears to me that you calculated the aggregate expression MaxOfActivityDescr. Shouldn't it be Count? And you should count the primary key (ID) or else you would count the number of activity types.

Mihai

Reply With Quote
  #3 (permalink)  
Old November 24th, 2004, 11:11 AM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your answer, I did some changings and I have some solution:

Code:
TRANSFORM Last(Q_GTMActivities.ActivityDescription) AS LastOfActivityDescription
SELECT Q_GTMActivities.ActivityType
FROM Q_GTMActivities
WHERE (((Q_GTMActivities.Reseller)="Company 1") AND ((Q_GTMActivities.ActivityYear)="2005"))
GROUP BY Q_GTMActivities.ActivityType, Q_GTMActivities.Reseller, Q_GTMActivities.ActivityYear, Q_GTMActivities.ActivityDescription
ORDER BY Q_GTMActivities.ActivityType
PIVOT Q_GTMActivities.ActivityMonth In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
The activity types are now repeated for all descriptions. I now want all activitytypes/month duplicated in one field...?!

Reply With Quote
  #4 (permalink)  
Old November 24th, 2004, 11:21 AM
Authorized User
 
Join Date: May 2004
Location: Bucharest, , Romania.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I imagine you have to cut out the repeated ActivitiyDescription Group By, since they are shown as value, but I can't understand exactly what you want.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
last activity updates with newsletter vantoko BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 July 25th, 2007 02:56 PM
bug in activity tracking vantoko BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 February 25th, 2007 11:29 AM
last activity time of a oracle session ravish_agarwal Oracle 1 April 11th, 2006 02:04 PM
capturing activity ozPATT Access VBA 2 December 21st, 2005 09:20 AM
An activity by user B trigger an event for A bigmish Classic ASP Basics 1 July 3rd, 2004 04:28 PM



All times are GMT -4. The time now is 11:39 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.