D
Dan McClelland
True or false: A saved crosstab query can be used as the
rowsource of a listbox, while a transform SQL statement
cannot.
Using Access XP. Trying to generate an SQL string
dynamically, then populate a listbox using that string.
Works fine unless the SQL string contains TRANSFORM.
However, setting the rowsource of the listbox to a saved
crosstab query works fine.
Specifics: User clicks on a football player's name in
listbox #1. The OnClick event fires, the PlayerID is
stored in a variable, and the rowsource of listbox #2 is
set to an SQL statement. (It is more complex than this,
which is why I'm not using a parameterized saved query.)
If I use a simple SQL statement like this, it works:
lstStats.RowSource = "SELECT PassingTDs FROM
tblPlayerStats WHERE (PlayerNo = " & lngPlayerID & ");"
However, as soon as I use a crosstab query SQL statement,
it does nothing, like this:
lstStats.RowSource = "TRANSFORM Sum(PassingTDs) SELECT
tblPlayerStats.StatYear FROM tblPlayerStats WHERE
(PlayerID = " & lngPlayerID & ") GROUP BY StatYear PIVOT
tblPlayerStats.StatType;"
If I take the above Transform statement and save it, then
use that persisted query as the rowsource (without the
concatenated variable of course), it works fine.
rowsource of a listbox, while a transform SQL statement
cannot.
Using Access XP. Trying to generate an SQL string
dynamically, then populate a listbox using that string.
Works fine unless the SQL string contains TRANSFORM.
However, setting the rowsource of the listbox to a saved
crosstab query works fine.
Specifics: User clicks on a football player's name in
listbox #1. The OnClick event fires, the PlayerID is
stored in a variable, and the rowsource of listbox #2 is
set to an SQL statement. (It is more complex than this,
which is why I'm not using a parameterized saved query.)
If I use a simple SQL statement like this, it works:
lstStats.RowSource = "SELECT PassingTDs FROM
tblPlayerStats WHERE (PlayerNo = " & lngPlayerID & ");"
However, as soon as I use a crosstab query SQL statement,
it does nothing, like this:
lstStats.RowSource = "TRANSFORM Sum(PassingTDs) SELECT
tblPlayerStats.StatYear FROM tblPlayerStats WHERE
(PlayerID = " & lngPlayerID & ") GROUP BY StatYear PIVOT
tblPlayerStats.StatType;"
If I take the above Transform statement and save it, then
use that persisted query as the rowsource (without the
concatenated variable of course), it works fine.