updating

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

peljo via AccessMonster.com

I have to update 12 fields called branch1,branch2,etc and also items1,items2,
etc amd i have to repeat 12 times my update query as :
Public Function UpdateTableProducts1()
Dim sql As String
' branch1
sql = "UPDATE products INNER JOIN products1 ON [products].[Productid]=
[products1].[Productid]" & _
" SET products1.branch1 = [products].[branch1], products1.items1 = [products].
[items1];"
CurrentDb.Execute sql
Dim sql As String
' branch2
sql = "UPDATE products INNER JOIN products1 ON [products].[Productid]=
[products1].[Productid]" & _
" SET products1.branch2 = [products].[branch2], products1.items2 = [products].
[items2];"
CurrentDb.Execute sql
End Function
etc
etc


is there a easier way of updating these fields?
 
hi,
I think you can do all in one SQL:

UPDATE products INNER JOIN products1 ON
[products].[Productid]=[products1].[Productid]
SET products1.branch1 = [products].[branch1], products1.items1 =
[products].[items1],
products1.branch2 = [products].[branch2], products1.items2 =
[products].[items2],
products1.branch3 = [products].[branch3], products1.items3 =
[products].[items3],
....
products1.branch12 = [products].[branch12], products1.items12 =
[products].[items12]

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
 
Back
Top