473,498 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UNION ALL causing #Error when used with DSUM

Hello all, hope someone can help.

I recently built a report showing the distribution of money in and out
of the company. Simplified version of which looks like:

DECEMBER 2004
TELEPHONE SALES: INTERNET: TOTAL:
£1200 £1000 £2200

I then built a sub-report showing adjustments, eg:

ADJUSTMENTS
TELEPHONE SALES: INTERNET: TOTAL:
Refund#1 £12 £1 £13
Refund#2 £2 £10 £12

Finally I created an overall totals for each column using the DSUM
function. Everything worked great. The sub-report is based on a UNION
query, and I realised that this was removing duplicates records, when
obviously in this context they should remain. I therefore changed the
underlying query to a UNION ALL query. This fixed the query in the
respect that it now returns all of the necessary records, however in
the report fields that reference the query using DSUM, the result
returned is '#Error'. I cannot see why this would be. What have I
done wrong? Or is it a bug? Any guidance greatly appreciated.

Nov 13 '05 #1
4 2063
st******@isoplan.co.uk wrote:
the report fields that reference the query using DSUM, the result
returned is '#Error'. I cannot see why this would be. What have I
done wrong? Or is it a bug? Any guidance greatly appreciated.


Do check if the control name collides with a field name. If so, rename
the control and see whether the #error goes away.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #2
It is definately to do with the UNION ALL command. If I go into the
underlying query and remove the word 'ALL' report works fine, error
goes away. Put 'ALL' back in and the error is back.
As a workaround I have added a new unique field to my underlying query,
so that no duplicates are returned, and I can use UNION rather than
UNION ALL. Seems more complicated than necessary, but it works.
Be interested to hear if anyone else out there has had problems with
this, and how they solved it.

Nov 13 '05 #3
st******@isoplan.co.uk wrote:
It is definately to do with the UNION ALL command. If I go into the
underlying query and remove the word 'ALL' report works fine, error
goes away. Put 'ALL' back in and the error is back.


Okay. What if you don't use DSum in the report, but grouping? In a group
footer you can use Sum([fieldname]).

Access does several things behind our backs when creating the datasource
for a report. Let's try several approaches in return :-)
--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #4
Access often misunderstands the data type of calculated fields.

Try typecasting the field in the first SELECT statement of the UNION query,
e.g.:
CCur(Nz(DSum("SomeField", "SomeTable), 0))

More info:
Calculated fields misinterpreted
at:
http://members.iinet.net.au/~allenbrowne/ser-45.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<st******@isoplan.co.uk> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
It is definately to do with the UNION ALL command. If I go into the
underlying query and remove the word 'ALL' report works fine, error
goes away. Put 'ALL' back in and the error is back.
As a workaround I have added a new unique field to my underlying query,
so that no duplicates are returned, and I can use UNION rather than
UNION ALL. Seems more complicated than necessary, but it works.
Be interested to hear if anyone else out there has had problems with
this, and how they solved it.

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5432
by: Matias Silva | last post by:
Hi Everyone, I wrote a for loop to build several select statements that are combined with a UNION. When I execute one of the queries separately, it works, but when I execute the query with a UNION...
6
3016
by: _link98 | last post by:
Problem: getting SQL0181N for queries on nicknames to remote Union-All-View. Can't see what I'm doing wrong yet, maybe someone has seen this before. Environment: UDB ESE 8.1 + FIXPAK 9A, on...
18
2359
by: ranjeet.gupta | last post by:
Dear ALL As we know that when we declare the union then we have the size of the union which is the size of the highest data type as in the below case the size should be 4 (For my case and...
8
4426
by: deercreek | last post by:
I have the following table test3. RESERVATIONID Site SitePrice 101 RV2 $25.00 101 RV3 $25.00 102 RV4 $25.00 102 RV5 $25.00 104 ...
8
5635
by: wkaras | last post by:
In my compiler, the following code generates an error: union U { int i; double d; }; U u; int *ip = &u.i; U *up = static_cast<U *>(ip); // error I have to change the cast to...
9
2900
by: Jeremy | last post by:
I have a situation where i am trying to run two query's and retrieve one record from each query, then using Union combine them into one recordset. The First Query is strait forward and should just...
3
4684
patjones
by: patjones | last post by:
Good morning all: In what seems like an ongoing saga to make the DSum function do what I need it to, I am now having trouble with a user-defined function in my VBA module. Here's the offending...
1
1769
by: joefrost | last post by:
I have the following SQL query that keeps giving me a runtime error 800a0401when running through an asp page. The query is below: SELECT (Sum(Abs(DSum("Cath_type","tbl1a_IC")))/10*100) AS...
7
1645
jmoudy77
by: jmoudy77 | last post by:
I've got some vb code that gives me a "previous operation cancelled" error when I try and open the form as a subform in a tabbed control. When I open the form itself I don't get the error. Does...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
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
7205
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
7379
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...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.