Results 1 to 2 of 2
  1. #1
    DADAZHU is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2011
    Posts
    10

    Help needed for SQL string - UPDATE

    Hi,



    I need some helps with UPDATE SQL string. I use ADO connection to an access DB. I have some tables as following,

    tblUnit: CC, Name, Cluster_ID, Area_ID, Type_ID
    tblClusterTable2: Cluster_ID, Cluster_Name
    tblArea: Area_ID, Area_Name
    tblType: Type_ID, Type_Name

    In user interface, users get to see the table1 info:CC, Name, Cluster_Name, Area_Name, Type_Name, and user can change the names except CC. I display the info by using inner join the tables without a problem. However, I ran into problems when I tried to update the tables if an user changes one or many of the names. My SQL is as below,

    strSQL = "UPDATE ((tblUnit" _
    & " INNER JOIN tblType ON tblUnit.Type_ID=tblType.Type_ID)" _
    & " INNER JOIN tblCluster ON tblUnit.Cluster_ID=tblCluster.Cluster_ID)" _
    & " INNER JOIN tblArea ON tblUnit.Area_ID = tblArea.Area_ID " _
    & " SET tblUnit.Unit_Name ='" & strUName & "'," _
    & " tblCluster.Name ='" & strCName & "'," _
    & " tblArea.Name ='" & strAName & "'," _
    & " tblType.Name ='" & strTName & "'" _
    & " WHERE CC ='" & strCC & "'"

    I need to update tblUnit only when an unit's profile is changed, eg. from an area to another,a Area_ID replaces another, and no change is to be made to all other tables, . However, when the SQL is executed, it seemed nothing happened, or sometime it went ahead and changed the other tables(eg. tblArea), and create duplated value.

    I hope I explain clearly. Please let me know if you need more info.

    Many thanks in advance.

  2. #2
    Guus2005's Avatar
    Guus2005 is offline Carbon based thingy
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2010
    Location
    the netherlands
    Posts
    42
    If you only want to change the tblUnit table, why are you setting the other fields in the other tables as well?
    Code:
    strSQL = "UPDATE ((tblUnit" _
    & " INNER JOIN tblType ON tblUnit.Type_ID=tblType.Type_ID)" _
    & " INNER JOIN tblCluster ON tblUnit.Cluster_ID=tblCluster.Cluster_ID)" _
    & " INNER JOIN tblArea ON tblUnit.Area_ID = tblArea.Area_ID " _
    & " SET tblUnit.Unit_Name ='" & strUName & "'," _
    & " tblCluster.Name ='" & strCName & "'," _
    & " tblArea.Name ='" & strAName & "'," _
    & " tblType.Name ='" & strTName & "'" _
    & " WHERE CC ='" & strCC & "'"
    HTH

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

Similar Threads

  1. Help Needed
    By sdecaire in forum Access
    Replies: 2
    Last Post: 11-11-2011, 03:07 PM
  2. Help Needed
    By vkmarty in forum Access
    Replies: 1
    Last Post: 09-23-2011, 07:23 AM
  3. Help needed With Update Query Setup
    By NewInAccessBusiness in forum Access
    Replies: 18
    Last Post: 06-08-2011, 12:29 AM
  4. Update Query Help Needed
    By Siobhan in forum Queries
    Replies: 5
    Last Post: 04-20-2011, 02:01 PM
  5. Use Table1 to update Table2? Urg Help needed
    By munkifisht in forum Queries
    Replies: 1
    Last Post: 07-24-2009, 08:00 AM

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