Results 1 to 6 of 6
  1. #1
    mp3909 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    154

    Add a column to a table and populate it all the way down to the last row of exiting data

    Hi,

    I use the docmd.transfertext to bring in data from a csv file into an access table.

    The access table is called "xyz".



    I now need to add a column right at the end of table "xyz" and fill in that column with the value "Dog" all the way down to the last used row of data.

    How can I do this in access vba.

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Sorry, misread question. Disregard.
    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
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    If you are importing into an existing Access table (and not creating a new table by virute of the import), all you need to do is to add this field to the table BEFORE you import it, and set the Default value as "Dog". Then any new record added to the table will have "Dog" populated in this field.

    Otherwise, you could simply run an Update Query to populate this field after import. You can do this in VBA very easily. Just set up the Append Query, and create a Macro that opens that Query. Then, select that query and select "Convert Macros to Visual Basic", and that will convert that command to VBA code for you.

  4. #4
    mp3909 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    154
    this is in access my friend, not excel vba

  5. #5
    mp3909 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    154
    Quote Originally Posted by June7 View Post
    Bing: excel vba autofill down to last row

    https://www.mrexcel.com/forum/excel-...-row-data.html
    this is in access, not excel vba

  6. #6
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Did you see my response?

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

Similar Threads

  1. Replies: 2
    Last Post: 09-12-2016, 11:00 AM
  2. Replies: 3
    Last Post: 07-06-2016, 09:48 AM
  3. Replies: 3
    Last Post: 03-27-2013, 02:17 PM
  4. Replies: 1
    Last Post: 10-24-2011, 04:11 PM
  5. Replies: 3
    Last Post: 05-19-2010, 10:08 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