Results 1 to 7 of 7
  1. #1
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398

    Appending records to a table

    Based on SQL string, I'm appending records to a table. How do I add,to my SQL string that I'd like to insert the text "New ID" into another field within the table that is being appended? Here is my SQL string:



    INSERT INTO PM_Audit ( Position_ID )
    SELECT PM_Current.Position_ID
    FROM PM_ARCHIVE_130802 RIGHT JOIN PM_Current ON PM_ARCHIVE_130802.Position_ID = PM_Current.Position_ID
    WHERE (((PM_ARCHIVE_130802.Position_ID) Is Null))

    So, within table PM_Audit, I have a field named "Activity." I'd like to have "New ID" inserted into that field for these records.

    Thank you in advance!!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Your issue seems to be the same as https://www.accessforums.net/access/...ery-37060.html

    If not, how do you generate this "New ID", where does it come from - on a form? Maybe:

    INSERT INTO PM_Audit ( Position_ID, Activity )
    SELECT PM_Current.Position_ID, Forms!formname!ID AS Activity
    FROM PM_ARCHIVE_130802 RIGHT JOIN PM_Current ON PM_ARCHIVE_130802.Position_ID = PM_Current.Position_ID
    WHERE (((PM_ARCHIVE_130802.Position_ID) Is Null))
    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. #3
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Based on the FROM and WHERE part of this SQL statement, these are new records. When these records are inserted into the table, I need to also insert "New ID" into another field within that table. "New ID" is not coming from any form.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Then where does it come from?
    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. #5
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    It's a label. I'm just trying to identify within this table that these are "New ID". I could label it anything.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    You want the literal text "New ID" in the Activity field? That's soooooo simple.


    INSERT INTO PM_Audit ( Position_ID, Activity )
    SELECT PM_Current.Position_ID, "New ID" AS Activity
    FROM PM_ARCHIVE_130802 RIGHT JOIN PM_Current ON PM_ARCHIVE_130802.Position_ID = PM_Current.Position_ID
    WHERE (((PM_ARCHIVE_130802.Position_ID) Is Null))
    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. #7
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Perfect!! Just what I wanted. Thanks for your assistance!!

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

Similar Threads

  1. Message before Appending Records
    By Lorlai in forum Programming
    Replies: 3
    Last Post: 03-19-2013, 04:51 PM
  2. Appending inventory records with current price records
    By sberti in forum Database Design
    Replies: 8
    Last Post: 11-29-2012, 10:24 PM
  3. Replies: 1
    Last Post: 06-19-2012, 06:12 PM
  4. show duplicate records when appending a table
    By bdaniel in forum Programming
    Replies: 1
    Last Post: 06-01-2011, 07:15 AM
  5. Key violation when appending records
    By slaterino in forum Programming
    Replies: 10
    Last Post: 08-26-2010, 08:25 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