Results 1 to 3 of 3
  1. #1
    compooper is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2011
    Posts
    87

    Question Access 2003: Import & Append New data

    Hi,



    I'm trying to find/write a code that will allow me to import separate csv files into separate tables.
    The table it will be imported to is determined like this:

    If cboCompany = CompanyA and cboInvType = TypeA then
    import to tbl_CompanyA_TypeA
    append txtinvoiceenddate to Invperiod
    If cboCompany = CompanyA and cboInvType = TypeB then
    import to tbl_CompanyA_TypeB
    append txtinvoiceenddate to Invperiod
    If cboCompany = CompanyB and cboInvType = TypeA then
    import to tbl_CompanyB_TypeA
    append txtinvoiceenddate to Invperiod

    What I mean by "append txtinvoiceenddate to Invperiod" that in each table there is a field called Invperiod (Invoice period)

    The user has to enter the invoice end date in a form.
    That date has to be added & repeat for all records in the newly imported file. It should not overwrite any existing records in the table.

    My idea is to just have lots of if statements and DoCmd.TransferSpreadsheet statements for the separate scenerios
    Is this efficient?
    And how do I add the invoice period to only the new data I am importing?
    Are there any sample databases out there, that import separate files into separate existing tables?

    I should add that I've already got the browse button and txtPath to work.

  2. #2
    compooper is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2011
    Posts
    87
    Just to test my idea I tried this:
    Private Sub cmdUpload_Click()
    If Me.cboCompany = 1 And Me.cboInvType = 2 Then
    DoCmd.TransferSpreadsheet acImportDelim, "", "Inv_companya_type1", Me.txtPath, True
    Else
    MsgBox "Error!!"
    End If
    End Sub

    I get Run-Time Error: '13' Type mismatch
    and when I press debug it highlights
    DoCmd.TransferSpreadsheet acImportDelim, "", "Inv_EXAM_Labs", Me.txtPath, True

  3. #3
    compooper is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2011
    Posts
    87
    Nevermind, it was supposed to be DoCmd.TransferText acImportDelim, "", "Inv_companya_type1", Me.txtPath, True

    New question:
    How can I delete the first row of the newly imported data (contains field headers, that I do not like)?
    Last edited by compooper; 06-22-2011 at 12:25 PM.

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

Similar Threads

  1. Access 2003: Import Specification
    By compooper in forum Import/Export Data
    Replies: 2
    Last Post: 08-23-2011, 01:58 PM
  2. Access 97 -Access 2003 import
    By modrec in forum Import/Export Data
    Replies: 3
    Last Post: 02-14-2011, 08:49 AM
  3. Excel Import/Append Data (weekly)
    By MartinL in forum Import/Export Data
    Replies: 1
    Last Post: 08-12-2010, 06:14 PM
  4. Import in Access (2003)
    By Claude in forum Programming
    Replies: 2
    Last Post: 06-18-2009, 12:49 AM
  5. Import Excel Worksheets into Access 2003
    By KramerJ in forum Programming
    Replies: 0
    Last Post: 03-18-2009, 04:11 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