Results 1 to 6 of 6
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    append data

    All; using 2010; I have a database in which I import 4 excel spreadsheets into temp tables. I want to append the data in temp tables to existing tables.
    I want user to be able to do the importing and appending from a form with a command button. I put code similar to this in a function along with code to import the excel spreadsheet (Transferspreadsheet...):
    Code:
    Dim srtQry1 As String, srtQry2 As String
    strQry1 = "INSERT INTO Order_Line (OrderNo, ProductID, Qty, Price) " & _
                  "SELECT OrderNo, ProductID, Qty, Price " & _
                  "FROM Import_Order_Lines;"
    strQry2 = "INSERT INTO Order (OrderNo, OrderDate, CurstomerName, CustomerDeliveryAddress, CustomerSuburb, CustomerState, CustomerPostCode) " & _
                  "SELECT OrderNo, OrderDate, CurstomerName, CustomerDeliveryAddress, CustomerSuburb, CustomerState, CustomerPostCode " & _
                  "FROM Import_Order_Lines;"
    DoCmd.RunSQL strQry1
    DoCmd.RunSQL strQry2
    Like i said; I have 4 tables. Is there a more proficient use of VBA that I can use or am I on the right track. How would you do this?


    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Only if you want to import directly into the final tables.
    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
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    So is this the best way to get the data into the final table?
    Thanks

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    By direct import to final table? Often. 'Best' approach depends on structures of the files. However, use of 'temp' tables is usually unnecessary step.
    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
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    thanks. Temp tables are to ensure data imported correctly from excel spreadsheet. Often more than not; data type does not hold when using Transferspreadsheet. Users get import errors if they forget to make sure the format is correct on the spreadsheet i.e. ID number is text not number.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Even setting format on Excel is no guarantee of error-free import. Now working with another poster having that issue.
    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.

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

Similar Threads

  1. Add/append data to crosstab query
    By DatabaseIntern in forum Queries
    Replies: 4
    Last Post: 08-02-2012, 10:15 AM
  2. append xml data and rename unique id
    By DanChirila in forum Import/Export Data
    Replies: 1
    Last Post: 04-01-2012, 11:39 AM
  3. Query append data from another database
    By Eagle2012 in forum Access
    Replies: 2
    Last Post: 03-17-2012, 03:02 PM
  4. Data append to table
    By ali zaib in forum Access
    Replies: 4
    Last Post: 01-13-2012, 11:22 AM
  5. Append Checkbox Data
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 06-29-2010, 04:58 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