The SQL I used I just copied from the three queries in the Query Design
window.. I just eliminated the actual names of the queries from the
statement above.
I hope you can help - I've been on this for a week now and have not made any
progress with the rest of my program.
Thanks
Laura TD
Laura,
sqlCurrentEvents = ("SELECT * FROM (TRANSFORM First(Event) AS
FirstOfEvent " _
& "SELECT fullname " _
& "FROM (SELECT tblAllDates.day, tblEvent.EventDate,
tblEvent.Event,
[sname] & ' ' & [fname] AS fullname " _
& "FROM tblAllDates LEFT JOIN (tblEvent LEFT JOIN tblEmployee ON
tblEvent.EmployeeID = tblEmployee.EmployeeID) ON tblAllDates.day =
tblEvent.EventDate " _
& "WHERE (((Month([day]))=Month(Date())) AND
((Year([day]))=Year(Date()))) " _
& "ORDER BY tblAllDates.day) " _
& "GROUP BY fullname " _
& "ORDER BY Format([day],'dd') & ' ' & Format([day],'ddd') " _
& "PIVOT Format([day],'dd') & ' ' & Format([day],'ddd')) " _
& "WHERE (((fullname)>''))")
The Query stripped of string assembly operators.
SELECT *
FROM (TRANSFORM First(Event) AS FirstOfEvent
SELECT fullname
FROM (SELECT tblAllDates.day
,tblEvent.EventDate
,tblEvent.Event
,[sname] & ' ' & [fname] AS fullname
FROM tblAllDates
LEFT JOIN
(tblEvent
LEFT JOIN tblEmployee
ON tblEvent.EmployeeID =
tblEmployee.EmployeeID)
ON tblAllDates.day = tblEvent.EventDate
WHERE (((Month([day])) = Month(Date()))
AND ((Year([day])) = Year(Date())))
ORDER BY tblAllDates.day)
GROUP BY fullname
ORDER BY Format([day],'dd') & ' ' & Format([day],'ddd')
PIVOT Format([day],'dd') & ' ' & Format([day],'ddd'))
WHERE (((fullname)>''))
The only troube is that you didn't post the *exact* SQL you were
working with. You said you replaced the query names with the actual
SQL. This creates a situation where I'm trying to figure out what's
going wrong for you, and I'm not looking at exactly what you are
using. You'll see what I mean in a second here.
Ok, first off, I'm pretty sure you can't do a TRANSFORM/PIVOT directly
on the FROM clause.
Here is a similar example (from my own list of test tables and
queries):
SELECT *
FROM (TRANSFORM IIF(MIN(T1.SelectionValue) < 0, "Y", "N")
SELECT T1.TransactionID
FROM FormsSelections AS T1
WHERE T1.SelectionValue = Yes
GROUP BY T1.TransactionID
PIVOT T1.SelectionType);
The CrossTab works ok by itself, but produces "Syntax error in FROM
clause" when I execute the above.
However, when I do (FindYesNo_FormsSelections is the name of the
Crosstab QueryDef above):
SELECT *
FROM FindYesNo_FormsSelections;
It works normally.
For you, try:
MyNewQueryDefName:
TRANSFORM First(Event) AS FirstOfEvent
SELECT fullname
FROM (SELECT tblAllDates.day
,tblEvent.EventDate
,tblEvent.Event
,[sname] & ' ' & [fname] AS fullname
FROM tblAllDates
LEFT JOIN
(tblEvent
LEFT JOIN tblEmployee
ON tblEvent.EmployeeID = tblEmployee.EmployeeID)
ON tblAllDates.day = tblEvent.EventDate
WHERE (((Month([day])) = Month(Date()))
AND ((Year([day])) = Year(Date())))
ORDER BY tblAllDates.day)
GROUP BY fullname
ORDER BY Format([day],'dd') & ' ' & Format([day],'ddd')
PIVOT Format([day],'dd') & ' ' & Format([day],'ddd')
SELECT *
FROM MyNewQueryDefName
WHERE (((fullname)>''))
I'm hoping that will work for you. (There, that is the trouble I
mentioned a little further back. If I read what you did correctly
from the beginning of your post, you already are looking at just this.
However, it works for me, but isn't working for you.)
I run Win2k SP-4, Access 2000 SP-3, JET SP-8.
However, now I'm curious. You've mentioned a "blank line". What do
mean by that?
Sincerely,
Chris O.