Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    cfobare79 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    66
    I tried the code below and received the error code: validation rule violation. Those to fields are set to the same data type.

    INSERT INTO DaveWelchTable (AgencyID)
    SELECT AgencyList.AgencyID


    FROM AgencyList
    INNER JOIN DaveWelchTable
    ON AgencyList.AgencyID = DaveWelchTable.AgencyID

  2. #17
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    DaveWelchTable is the imported dataset? Why would you be inserting records into DaveWelchTable? Don't you need to insert DaveWelchTable records into another table? And if the imported data does not have AgencyID, how can you equate the fields?

    If you want to retain DaveWelchTable permanently in the db, then you need to do an UPDATE on its AgencyID field.

    UPDATE DaveWelchTable SET DaveWelchTable.AgencyID = AgencyList.AgencyID FROM DaveWelchTable, AgencyList WHERE DaveWelchTable.AgencyName = AgencyList.AgencyName

    Validation rule violation does not pertain to data type mismatch error.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #18
    cfobare79 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    66
    What I want to do is take AgencyID from AgencyList (AgencyList.AgencyID) by matching AgencyName from both DaveWelchTable and AgencyList and have it inserted into DaveWelchTable. I was a bit confused with the questions from the last post and that SQL didn't work.

  4. #19
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    What does 'did not work' mean - error message, wrong results, nothing happened?

    Look closely at your INSERT statement and try to see the illogic of that approach. What you now describe is an UPDATE action. The suggested statement has correct syntax.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #20
    cfobare79 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    66
    Click image for larger version. 

Name:	Capture.PNG 
Views:	5 
Size:	12.2 KB 
ID:	20560This is exactly what appears when I use the code as given.

  6. #21
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Bing: update field with data from another table

    http://stackoverflow.com/questions/4...r-table-in-sql

    I don't see anything wrong with the statement.

    An alternative SQL to try:

    UPDATE DaveWelchTable INNER JOIN AgencyList ON DaveWelchTable.AgencyName = AgencyList.AgencyName SET DaveWelchTable.AgencyID = AgencyList.AgencyID

    Perhaps you should use the query builder and let it build the SQL statement instead of just pasting into the SQL window.

    I seldom run INSERT or UPDATE that involves two tables.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #22
    cfobare79 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    66
    worked perfectly that time... You are AWESOME... Have a wonderful weekend.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Need to Merge 6 Similar Tables
    By CJS in forum Queries
    Replies: 6
    Last Post: 04-21-2015, 10:14 AM
  2. how to merge two or more tables horizontally with vba?
    By registoni in forum Programming
    Replies: 2
    Last Post: 09-20-2013, 06:43 AM
  3. Don't know if I should merge tables (please help)
    By bigdaddy757 in forum Database Design
    Replies: 2
    Last Post: 05-30-2013, 01:52 PM
  4. Merge linked tables!
    By thaonguyen1013 in forum Access
    Replies: 14
    Last Post: 02-01-2012, 04:03 PM
  5. How do I Merge Four Tables Together
    By SteveI in forum Queries
    Replies: 1
    Last Post: 03-04-2010, 10:53 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