Results 1 to 7 of 7

Thread: Create Access database on the fly & import csv/txt file as table!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Maybe another way to do it is to create a .csv file from Excel and use a script to populate a table? Like this:

    Const adOpenStatic = 3Const
     adLockOptimistic = 3Const ForReading = 1Set
     objConnection = CreateObject("ADODB.Connection")Set objRecordSet = CreateObject("ADODB.Recordset")objConnection.Open _ 
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _    
    "Data Source = c:\scripts\test.mdb" objRecordSet.Open "SELECT * FROM Employees", _  
    objConnection, adOpenStatic, adLockOptimisticSet objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.txt")Do Until objFile.AtEndOfStream  
    strEmployee = objFile.ReadLine  arrEmployee = Split(strEmployee, ",")  
    objRecordSet.AddNew 
    objRecordSet("EmployeeID") = arrEmployee(0)
    objRecordSet("EmployeeName") = arrEmployee(1)
    objRecordSet("Department") = arrEmployee(2) 
    objRecordSet.UpdateLoopobjRecordSet.CloseobjConnection.Close
    Last edited by Aussiebear; 01-12-2025 at 03:30 AM.
    Peace of mind is found in some of the strangest places.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •