Access query read from Excel doesn't show the same values

Dylan41

New member
Local time
Today, 03:19
Joined
Jun 9, 2020
Messages
5
In Excel I linked an Access query but some values are not shown correctly. Imagine I have TableA with these values:
Description | Value1 | Value2 | Value3 | Quantity
Bricks | 12.32 | 1.22 | 5.03 | 2
Wood | 12.22 | 1.1 | 5.55 | 1
Steel | 12.1 | 2.2 | 5.12 | 3

In a query, I have:
SELECT TableA.[Description], TableA.[Value1], TableA.[Value2], TableA.[Value3], TableA.[Value1]+TableA.[Value2]+TableA.[Value3] AS SumOfValues
FROM TableA

Then, in Access I have:
Description | Value1 | Value2 | Value3 | SumOfValues
Bricks | 12.32 | 1.22 | 5.03 | 18.57
Wood | 12.22 | 1.1 | 5.55 | 18.87
Steel | 12.1 | 2.2 | 5.12 | 19.42

But when I link that query from Excel, in Excel I have:

Description | Value1 | Value2 | Value3 | SumOfValues
Bricks | 12.32 | 1.22 | 5.03 | 18.57
Wood | 12.22 | 1.1 | 5.55 | 28.77
Steel | 12.1 | 2.2 | 5.12 | 148.12

i.e, the second row is calculated as 12.22+11+5.55 and the third row is calculated as 121+22+5.12

I tried to put 2 decimals in each value, but I couldn't. I tried Format([..], "Fixed") but it concatenates the values, it doesn't make a sum

What can I do?

Thanks
 
What are the data types on the fields in their original Access tables?
 
General in all of them. I tried using numeric and 2 decimals but it didn't work
 
There is no "General" datatype in Access.

This is because Format returns a string.

I mean, in Property Sheet it says:
Description:
Format:
Decimal places:
Input mask:
Caption:


All is blank
 
I wonder if you are using Decimal datatype and the problem is a variant of this issue.

Decimal stores numbers as scaled integers and it might be getting the scale wrong because of the first entry which has two decimal places.
 
Create a Query (qryMasonry) in Access:
Code:
SELECT tblMasonry.Description,
    tblMasonry.Value1,
    tblMasonry.Value2,
    tblMasonry.Value3,
    [Value1]+[Value2]+[Value3] AS SumOfValues
FROM tblMasonry;
Link (Data->Get Data->From Database) the qryMasonry to Excel.
 
Create a Query (qryMasonry) in Access:
Code:
SELECT tblMasonry.Description,
    tblMasonry.Value1,
    tblMasonry.Value2,
    tblMasonry.Value3,
    [Value1]+[Value2]+[Value3] AS SumOfValues
FROM tblMasonry;
Link (Data->Get Data->From Database) the qryMasonry to Excel.

That's what I did. I called it from Excel (Data -> Get External Data -> From Access). Then, I go to the table and select Data -> Properties. And, if the query is called qryMasonry, I write SELECT * FROM `qryMasonry`.

Is that OK?
 
I cannot replicate this issue.

Don't enclose qryMasonry in apostrophes. Could just simply reference the query name, no need for SELECT statement.
 

Users who are viewing this thread

Back
Top Bottom