Steve
Thanks for your help.
The full SQL code for the query used by the report and the partial code that
is being picked up by qdf.SQL is below. It is quite long and, I suspect, a
bit messy. Whenever I was asked to include a new field in the report I added
another query/table into the query being used by the report.
The field that the report is spit on is [Owner Code].
Partial code in qdf.SQL:-
"SELECT [Eff Data].[Eff Code], IIf([Data 0708]![0708 Total to
date]=0,False,True) AS [Include on Report], [Strategies & Actions].Strategy,
[Strategies & Actions].[Key Actions], [Eff Data].Owner, Owner.[test email],
Owner.Service, [Eff Data].[Efficiency A"
Full SQL Code:-
SELECT [Eff Data].[Eff Code], IIf([Data 0708]![0708 Total to
date]=0,False,True) AS [Include on Report], [Strategies & Actions].Strategy,
[Strategies & Actions].[Key Actions], [Eff Data].Owner, Owner.[test email],
Owner.Service, [Eff Data].[Efficiency Area], [Eff Data].[XL Ref], [Eff
Data].[Additional Notes], [Efficiency Area].EffSortNo, [Efficiency
Area].Desc, Owner.[Owner Name], [Data 0405].[Add Cum 0405] AS [Totals 0405],
[Data 0405].[Add Cum Cash 0405] AS [Cashable Totals 0405], [Data 0506].[0506
Total to date] AS [Totals 0506], [Data 0506].[0506 Cash to date] AS [Cashable
Totals 0506], [Data 0607].[0607 Total to date] AS [Totals 0607], [Data
0607].[0607 Cash to date] AS [Cashable Totals 0607], [Data 0708].[0708 Total
to date] AS [Totals 0708], [Data 0708].[0708 Cash to date] AS [Cashable
Totals 0708], [Strategies & Actions].[0506 Mid Year Review], [Strategies &
Actions].Contact, [6Mth Totals 0506].[6mthTotals 0506], [6Mth Totals
0506].[6mthCashables 0506], [Original Totals 0506].[OrigTotals 0506],
[Original Totals 0506].[OrigCashables 0506], [Strategies & Actions].[0506 EOY
Review], [Strategies & Actions].[Notes 1], [Strategies & Actions].[Notes 2],
[Data 0506].[Add Cum 0506], [Data 0506].[Add Cum Cash 0506], [Data
0506].[0506 Add], [Data 0506].[0506 cash add], [Data 0607].[Add Cum 0607],
[Data 0607].[Add Cum Cash 0607], [Data 0607].[0607 Add], [Data 0607].[0607
cash add], [Data 0708].[Add Cum 0708], [Data 0708].[Add Cum Cash 0708], [Data
0708].[0708 Total to date], [Data 0708].[0708 Cash to date], [Data
0708].[0708 Add], [Data 0708].[0708 cash add], [Totals 0405]+[Totals 0506] AS
[Cum Total to 0506], [Cum Total to 0506]+[Totals 0607] AS [Cum Total to
0607], [Cum Total to 0607]+[Totals 0708] AS [Cum Total to 0708], [Cashable
Totals 0405]+[Cashable Totals 0506] AS [Cashable to 0506], [Cashable To
0506]+[Cashable Totals 0607] AS [Cashable to 0607], [Cashable To
0607]+[Cashable Totals 0708] AS [Cashable to 0708]
FROM (((((((([Strategies & Actions] RIGHT JOIN [Eff Data] ON [Strategies &
Actions].[Efficiency No] = [Eff Data].[Eff Code]) LEFT JOIN [Efficiency Area]
ON [Eff Data].[Efficiency Area] = [Efficiency Area].Code) LEFT JOIN Owner ON
[Eff Data].Owner = Owner.[Owner Code]) LEFT JOIN [6Mth Totals 0506] ON [Eff
Data].[Eff Code] = [6Mth Totals 0506].[Eff Code]) LEFT JOIN [Original Totals
0506] ON [Eff Data].[Eff Code] = [Original Totals 0506].[Eff Code]) LEFT JOIN
[Data 0405] ON [Eff Data].[Eff Code] = [Data 0405].[Eff Code]) LEFT JOIN
[Data 0506] ON [Eff Data].[Eff Code] = [Data 0506].[Eff Code]) LEFT JOIN
[Data 0607] ON [Eff Data].[Eff Code] = [Data 0607].[Eff Code]) LEFT JOIN
[Data 0708] ON [Eff Data].[Eff Code] = [Data 0708].[Eff Code];
Steve Schapel said:
Mike,
I don't know what the problem here is. This code works fine for me with
long SQL statements. I will investigate. Can you post back with the
full SQL view of the query please? ... Just in case there is something
that gives a clue. Thanks.
--
Steve Schapel, Microsoft Access MVP
MikeS3416 wrote:
Thanks for your help. Sorry about the delay in replying - I've been away.
I have a problem with the SQL code. I assume that “qdf.SQL†picks up the SQL
statement behind the query in “dbs.QueryDefs("YourReportQuery")â€. In this
case the SQL statement should be 2689 characters. What is actually coming
through to “qdf.SQL†is only the first 253 characters. This results in
"Run-time errror '3129'. Invalid SQL statement....." when it gets to the line
"qdf.SQL = BaseSQLâ€.