Results 1 to 2 of 2

Thread: updating

  1. #1
    Join Date
    Mar 2006
    Posts
    42

    Unanswered: updating

    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?

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Yes.

    Code:
    For I = 1 to 12
       <your code using i as the bit that identifies which table, field etc>
    Next
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •