SCWED Test

Dassudt

New Member
Joined
May 7, 2017
Messages
16
Hi kindly advice below;
Code:
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
 
Last edited by a moderator:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
First follow the forum rules and add code tags and consider being descriptive about your needs

second, what are you looking for advice with
 
Upvote 0

Forum statistics

Threads
1,215,340
Messages
6,124,382
Members
449,155
Latest member
ravioli44

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