Results 1 to 4 of 4
  1. #1
    vjorden is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Posts
    2

    Append Query to add column?

    Hi Everyone!



    I am a self taught Access user, I know a little VBA but not much.

    Here is my issue: I currently have a database populated with thousands of records and now all of a sudden the folks I work for want to add in another column of data. The primary key main table are SSN. I have an excel spreadsheet with this new column of data and the related SSN.

    I do not want to have to data entry each of these values, so how can I get the data for this new column into the associated rows?

    My first thought was an append query...but I just can't seem to get it to work. Any ideas on how best to get this done?

    Thanks!

    VJ

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Append queries do not add columns to tables. It is very, very rare to have to add a column to a table in a properly normalized database. So, that might be an indication that yours is not correctly designed in the first place. But, be that as it may, you would need to use an ALTER TABLE SQL statement.

    So, anyway, you should just open the table in design view and add the extra column, import the data to a temporary table and then use an UPDATE query to update the existing data.

  3. #3
    vjorden is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Posts
    2
    Thanks Bob! I understand it is rare, they were tracking the info in a separate department and have now decided they want me to start tracking the info. If only they could have seen the light of centralizing information to begin with!

    I actually tried an update query as well with little success. I imported the info from the excel spreadsheet into a table, added the new column to the main table and set up the update query but am having no luck...the main table is not showing the new info even after I run the update query.

    Any tips or things I should make sure I am doing to get it run correctly?

    Thanks for your help...I appreciate it!

    VJ

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    So, first off you would

    1. Add the new field into the main table (setting the correct datatype as well).
    2. Then you would import the spreadsheet and tell it to use a NEW TABLE.
    3. Then you would use an Update Query to update the existing records in the field in the main table by using an Update query like this (changing the names to your actual names)
    Code:
    UPDATE MainTableNameHere 
    INNER JOIN ImportedTableNameHere 
    ON MainTableNameHere.IDFieldNameHere=ImportedTableNameHere.IDFieldNameHere 
    SET MainTableNameHere.FieldToUpdateNameHere= [ImportedTableNameHere].[FieldWithNewDataHere]
    WHERE (((ImportedTableNameHere.IDFieldNameHere)=[MainTableNameHere].[IDFieldNameHere]));

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

Similar Threads

  1. Replies: 7
    Last Post: 07-21-2011, 01:01 PM
  2. append query help
    By SlowPoke in forum Access
    Replies: 2
    Last Post: 09-25-2010, 10:47 AM
  3. Replies: 7
    Last Post: 04-27-2010, 02:47 PM
  4. Append query won't append
    By yelkenli in forum Queries
    Replies: 5
    Last Post: 02-12-2010, 11:19 AM
  5. Append Query
    By aabh in forum Queries
    Replies: 6
    Last Post: 02-02-2010, 04:26 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