Click to See Complete Forum and Search --> : updating


peljo
12-29-2007, 03:27 AM
I want to make an update code without referring to the form

My update query reads in is sql as follows
Dim SQL As String
StrSQL = "UPDATE products SET products.new = [products].[grossprice]-[products].[grossprice]*28/100"
I want to rewrite it in the following way :
Dim Diff As String
Diff = [products].[grossprice] - [products].[grossprice]
SQL = "UPDATE products SET products.new = diff*28/100 "

However this effort fails since i have to refer to a form.Can i build a code without referring to a form?

Phil Weber
12-29-2007, 03:38 AM
I don't think that will work. You want to set the [new] field of each product equal to that product's grossprice less 28%, correct? If you calculate diff once and pass it into the query, it will set [new] to the first product's grossprice - 28%; it will not recalculate diff for each product.