ignor the string in my maths and put 0 if it is

rainbows

Registered User.
Local time
Today, 07:37
Joined
Apr 21, 2017
Messages
428
hi, i have discovered that the sales people need to put a value or text in the feild called " intcoterms , i also see they have not been entering any date in that field also so i will default that to 0
what i am trying to do is add the "expr1" field value to the " sum of ordertotal field " so for example the top line would now have a total of "11300"
line 2 would stay at "24682" etc etc

any help appreciated

steve




1702225789960.png
 
You didn't show us the expression you're using. Are you already using the Nz() function in it?
 
after nearly 400 posts, you should know by now to provide the information that would enable us to help you. We shouldn't have to keep asking for it.

So I'm not going to ask, I'll wait for you to think about what is needed to solve your problem and for you to then provide it.
 
You require a value in that field. Access supports that by allowing you to make the field "Required".
Open the table in design view and change "No" to "Yes"
1702227433296.png


You can also assign 0 as the Default Value for the field in question. This screen shot shows a text field, but yours, of course, will be a number.
 
SELECT [Order Details].BatchNo, Orders.OrderID, [Order Details].OrderDetailID, Orders.CustomerName, Orders.OrderNo, Orders.NCONo, [Order Details].ProductNo, [Order Details].OrderQty, Sum([OrderQty]*[Price]) AS OrderTotal, [Acknwoledge order].intcoterms, Orders.[Exchange rate2], [intcoterms]*[exchange rate2] AS Expr1
FROM (Orders INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID) INNER JOIN [Acknwoledge order] ON Orders.NCONo = [Acknwoledge order].[NCO No]
GROUP BY [Order Details].BatchNo, Orders.OrderID, [Order Details].OrderDetailID, Orders.CustomerName, Orders.OrderNo, Orders.NCONo, [Order Details].ProductNo, [Order Details].OrderQty, [Acknwoledge order].intcoterms, Orders.[Exchange rate2];


hopefully i have sent what you need to look at to help me
 
Access supports that by allowing you to make the field "Required".
think it needs more than that since it is also required to be a numeric value for the calculation to work - all those #error's
 
The simplest solution is to:
1. Backup the BE
2. Update all the null values to 0
3. Change the table to make the numeric field required.
4. You need to decide if you want to force a value by leaving the default null or add 0 as the default. Not all numbers should automatically default to 0.

If you don't make the field required and specify 0 as the default, you MUST always handle nulls in all queries that do calculations or concatenations with these fields.

Things like OrderQty might make more sense to default to 1 since why place an order for a zero quantity. The price being 0 is different since there are reasons for not charging for an item.

In the meantime, see if this helps.

SELECT [Order Details].BatchNo, Orders.OrderID, [Order Details].OrderDetailID, Orders.CustomerName, Orders.OrderNo, Orders.NCONo, [Order Details].ProductNo, ([Order Details].OrderQty, Sum(Nz([OrderQty],1) * Nz([Price],0)) AS OrderTotal, [Acknwoledge order].intcoterms, Orders.[Exchange rate2], Nz([intcoterms],0) * Nz([exchange rate2], 1) AS Expr1
FROM (Orders INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID) INNER JOIN [Acknwoledge order] ON Orders.NCONo = [Acknwoledge order].[NCO No]
GROUP BY [Order Details].BatchNo, Orders.OrderID, [Order Details].OrderDetailID, Orders.CustomerName, Orders.OrderNo, Orders.NCONo, [Order Details].ProductNo, [Order Details].OrderQty, [Acknwoledge order].intcoterms, Orders.[Exchange rate2];

I had [Exchange Rate2] also default to 1 so there would be no conversion. Do what makes sense.

Also note that both OrderQty and [Exchange rate2] are in the group by.

And finally, the Group By makes no sense. It seems to include the PK of the OrderDetails table so no aggregation will ever take place.
 
1702231193807.png



i have changed the SQL but still got the error in " expri " field
and yes i will change the feilds in the table . at this time i took a copy of the backend to test everything

steve
 
think you need

Expr1: iif(isnumeric([intcoterms]),[intcoterms],0) * Nz([exchange rate2], 1)

(isnumeric will return false if intcoterms is null

edit: missed a bracket
 
Last edited:
How on earth do you expect to do maths on text? :-(

This would at least set it to 0, though I think you need to rethink what you are doing and what you are using? :-(

Code:
?nz(val("EXW"),0)
 0
 
1702232362258.png


i know , i could not believe it when i started to check on all the work they are doing on this database as i thought i was for packing and shipment cost ( i now guess not ) so i was trying to do a quick fix until i can find out exactly what it is for . even if i have to put another field in later
 
just for information

this also dont take into account the packing costs i just mentioned from the intcoterms field
Order Totals by Customer Order Totals by Customer

CustomerNameOrderTotalGrandTotalPct
London Underground Ltd
548,436.44​
1,646,245.52​
33.31%​
GE Energy Power Conversion Ltd
128,918.00​
1,646,245.52​
7.83%​
Pontificia Universidad Catolica De Chile
99,250.00​
1,646,245.52​
6.03%​
Applied Acoustic Engineering Limited
81,639.01​
1,646,245.52​
4.96%​
GE Power Conversion India Pvt. Ltd.
69,930.00​
1,646,245.52​
4.25%​
1702232832444.png
 
yes thank you this works , but i will re design it

iif(isnumeric([intcoterms]),[intcoterms],0) * Nz([exchange rate2], 1)

thanks everyone for your help
 
Silly me for not checking. I assumed that math was being done on numeric fields.

RI is not enforced AND The relationship between the order header and the ack is WRONG. Relationships are not data field to data field. They are PK to data field. The corrected relationship is probably.
1. remove NCONo from the order header
2. add OrderID to the ack table.

Your programmers seem to need more supervision. Walkthroughs are usually helpful and everybody learns from them.
 
think it needs more than that since it is also required to be a numeric value for the calculation to work - all those #error's
Below the screenshot:

"You can also assign 0 as the Default Value for the field in question. This screen shot shows a text field, but yours, of course, will be a number."
 

Users who are viewing this thread

Back
Top Bottom