Results 1 to 4 of 4
  1. #1
    WickidWe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    123

    Update Query for multiple tables VBA

    the code I have works fine.


    How can I add another update to another table?

    Add to query below: tblFunctions SET FctnSelected = True

    Code:
    dbs.Execute ("UPDATE tblEmpDetails SET IsVisible = False " _
    & "WHERE EmpID='" & Me.listEmp.Column(0, varItm) & "'")

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Using the same criteria??

    Try
    Code:
    dbs.Execute ("UPDATE tblEmpDetails SET IsVisible = False WHERE EmpID='" & Me.listEmp.Column(0, varItm) & "'")
    
    dbs.Execute ("UPDATE tblFunctions SET FctnSelected = True WHERE EmpID='" & Me.listEmp.Column(0, varItm) & "'")
    Not really sure what you are asking......

  3. #3
    WickidWe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    123
    thanks, also need to add an "AND" to the second one

    Tac on to the "WHERE" somehow:
    EmpID='" & Me.listEmp.Column(3, varItm) & "'

    To:
    dbs.Execute ("UPDATE tblFunctions SET FctnSelected = True WHERE EmpID='" & Me.listEmp.Column(0, varItm) & "'")

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Your sentences are too short and unclear. Really difficult to decipher what you are asking.

    Do you want
    Code:
    dbs.Execute ("UPDATE tblFunctions SET FctnSelected = True WHERE EmpID='" & Me.listEmp.Column(3, varItm) & "'")
    or

    Code:
    dbs.Execute ("UPDATE tblFunctions SET FctnSelected = True WHERE EmpID='" & Me.listEmp.Column(0, varItm) & "' AND EmpID='" & Me.listEmp.Column(3, varItm) & "'")
    The second one probably won't work because "EmpID" cannot be equal to Me.listEmp.Column(0, varItm) at the same time it is equal to Me.listEmp.Column(3, varItm)


    Explain it like:
    I want to update FctnSelected to TRUE in table tblFunctions when (Where) EmpID equals xxxx
    and when a_SecondField equals yyyy

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 08-09-2012, 01:07 PM
  2. Update multiple tables
    By DADAZHU in forum Access
    Replies: 8
    Last Post: 12-07-2011, 09:05 AM
  3. Replies: 10
    Last Post: 07-12-2011, 11:09 PM
  4. INSERT INTO and UPDATE to multiple tables
    By lupis in forum Import/Export Data
    Replies: 6
    Last Post: 05-19-2010, 05:21 AM
  5. Update Multiple tables from one form
    By KenK in forum Forms
    Replies: 0
    Last Post: 10-30-2009, 08:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums