SCWED Access Import

Dassudt

New Member
Joined
May 7, 2017
Messages
16
Sub ImportCS()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim qdf1 As DAO.Database
Dim rst As DAO.Recordset

Dim strSQL As String
Dim filepath As String
Dim filepath2 As String
filepath = CurrentProject.Path & "\User1.csv"
filepath2 = CurrentProject.Path & "\User2.csv"
Set db = CurrentDb
On Error Resume Next: db.TableDefs.Delete "tblImport": On Error GoTo 0
db.TableDefs.Refresh
DoCmd.TransferText TransferType:=acLinkDelim, TableName:="tblImport", _
FileName:="C:\Users\Sindhu\Downloads\ExcelSence\Access\Book1.csv", HasFieldNames:=True
DoCmd.TransferText TransferType:=acLinkDelim, TableName:="tblImport2", _
FileName:="C:\Users\Sindhu\Downloads\ExcelSence\Access\Book2.csv", HasFieldNames:=True
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO User1 (Name, Address, City, salary, DOJ, DOR) SELECT * FROM (tblImport)", 0
DoCmd.RunSQL "INSERT INTO User2 (Name, Country, UID, DOJ, DOR) SELECT * FROM (tblImport2)", 0
DoCmd.DeleteObject acTable, "tblImport"
DoCmd.DeleteObject acTable, "tblImport2"
DoCmd.SetWarnings True
Set dbs = CurrentDb
DoCmd.DeleteObject acQuery, "INNERQuarter"
'Access.CurrentDb.QueryDefs dbLocal.QueryDefs.Refresh
'Set qdf1 = dbLocal.CreateQueryDef(INNERQuarter)
strSQL = "Select User1.Name, User2.UID FROM (User1 INNER JOIN User2 ON User1.Name=User2.Name)"
Set qdf = dbs.CreateQueryDef("INNERQuarter", strSQL)
End Sub

I couldn't run my append cells, how to close excel files.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,215,943
Messages
6,127,826
Members
449,411
Latest member
adunn_23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top