addition with 0

  • Thread starter Thread starter peljo via AccessMonster.com
  • Start date Start date
P

peljo via AccessMonster.com

My update function does not always work properly, especially when one of the
fields is 0 or blank.How could i improve my function so that when addding wih
0 not to give 0 ?

My function is the following:
Public Function dummy()
StrSQL = " UPDATE (products1 INNER JOIN products ON products1.Productid =
products.Productid) INNER JOIN [Order Details1] ON " & _
" products1.Productid = [Order Details1].productid SET products1.items1 =
[order details1].[quantity]+[products1].[items1]"
End Function
 
This approach is not going to work.

You can use Nz() to convert the nulls to zeros, e.g.:
SET products1.items1 =
Nz([order details1].[quantity],0) + Nz([products1].[items1],0)

But there are other issues that will prevent this from working reliably,
e.g.:
a) Storing the total in the products table is not a good idea.
It should be calculated when needed.

b) Your query is not aggregating orders by product, so there's lots of room
for error here.

c) Incrementing the total like this guarantees that the total will gradually
become more and more wrong as time goes by.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

updating 1
delete query 1
Update query 3
Syntax error 2
Update query 2
Delete query 1
Unable to save subform field data to table 2
Save value from subform to table 1

Back
Top