Ask Experts Questions for FREE Help !
Ask
    jakester's Avatar
    jakester Posts: 582, Reputation: 165
    Senior Member
     
    #1

    Sep 23, 2011, 03:03 PM
    VBA code that will append Excel Data to an Access Table
    Ok, I'm fairly comfortable using VBA with Excel but now I am starting to use Access more. That said, I have a learning curve there.

    Here's what I am trying to do. I use a software system that allows me to export data to Excel. It does have a built-in function to export to Access but it doesn't work correctly so I am stuck using Excel. At any rate, I run a daily report that I would like to append each day from Excel to an existing table in my database.

    The database pathname is: P:\Phoenix\Workforce Mgt\Workforce Mgt Database.mdb and the table that I want to append data to is: Spec Ref Adherence Data.

    The table has six fields:

    1) ID (which is just an autonumber field)
    2) Agent Name
    3) Phone Hrs
    4) Missed Hrs
    5) Adherence
    6) Work Date

    The pathname that I store the Excel file in is located:

    H:\Adherence Data for Spec Ref - data dump.xls

    Basically, the field names in the Table match the field names in the Excel spreadsheet, minus the ID field.

    Currently I am using Microsoft Access 2007.

    Thanks for your help.

    Jake
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #2

    Sep 23, 2011, 03:39 PM
    Start with a TransferSpreadsheet method to LINK to the Excel sheet. Then run an APPEND query to add the records to your Access table.

    We are talking about TWO lines of code. Plus you create the Append query.
    jakester's Avatar
    jakester Posts: 582, Reputation: 165
    Senior Member
     
    #3

    Sep 24, 2011, 08:32 AM
    Quote Originally Posted by ScottGem View Post
    Start off with a TransferSpreadsheet method to LINK to the Excel sheet. Then run an APPEND query to add the records to your Access table.

    We are talking about TWO lines of code. Plus you create the Append query.
    Scott - I'd like to do this in Excel if possible. Once I download the data to Excel from my system, I have a macro that applies some formatting and removes columns that I don't need. The last line of that macro I'd like to be the part which tells Access to run the Append query without me manually having to open Access and then run the TransferSpreadsheet method.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #4

    Sep 24, 2011, 08:54 AM
    I work from the Access side, Access VBA is much easier to work with and, more important, much easier to debug. So I'm not sure how or if you can do this from Excel.

    One thing you can do, is create a front end specifically to run the TransferSpreadsheet. Run it from an autoexec macro. Then run that front end using the Shell command.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search


Check out some similar questions!

How to export excel data to access 2003 [ 1 Answers ]

I use Teradata SQL and pull a lot of data, need to learn how to export the data to Access 2003

Collect data into 2 combo boxes from data in an access table [ 1 Answers ]

I have two combo boxes. When the form loads the db connection opens a recordset that selects all the data from the retaillocations table. When you choose the region (0-4), that number loads into a text box and the Contacts load into the forst combo box. Now I want to select only the Name based on...

Export access table to Excel format [ 1 Answers ]

Hi, I am trying following code its working fine. Private Sub Command3_Click() 'Export function 'EXPORTS TABLE IN ACCESS DATABASE TO EXCEL 'REFERENCE TO DAO IS REQUIRED Dim strExcelFile As String Dim strWorksheet As String

Can I create records with OLE objects in Access & append to a linked SQLServer table? [ 2 Answers ]

There's a table in our SQL Server Database that stores various notes. There are text fields for the type of notation ( i.e. C = Customer, V=Vendor notes etc) and one for the "Owner_ID" (ie the Customer ID or Vendor ID). There's a date field for the create date of the note and the notes themselves...


View more questions Search