Dim A As Object
Dim MyAccess As Database
Dim MyQuery As String
Dim MyNewQuery
Dim MyTemp As DAO.Recordset
Dim xSelect As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.StatusBar = "Importing Data From Access"
Sheets("Import").Visible = True
xdate = [dDate]
Smonthdate = Sheet5.Cells(5, 6)
Emonthdate = Sheet5.Cells(5, 7)
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Sheets("Import").Select
Range("AST").Select
Selection.ClearContents
Set MyAccess = OpenDatabase("database path")
xSelect = " SELECT Ttable.Agent_Name, Ttable.Login_Id, Sum(Ttable.STime) AS SumOfSTime, Sum(Ttable.AXTime) AS SumOfAXTime, Sum(Ttable.[0Time]) AS SumOf0Time, Sum(Ttable.PBTime) AS SumOfPBTime, Sum(Ttable.DBTime) AS SumOfDBTime, Sum(Ttable.MTime) AS SumOfMTime, Sum(Ttable.TTime) AS SumOfTTime, Sum(Ttable.ITTime) AS SumOfITTime, Sum(Ttable.TETime) AS SumOfTETime, Sum(Ttable.PRTime) AS SumOfPRTime, Sum(Ttable.B1Time) AS SumOfB1Time, Sum(Ttable.B2Time) AS SumOfB2Time " & _
"FROM Ttable " & _
"WHERE (((Ttable.DATE)>=" & CDbl(Smonthdate) & " And (Ttable.DATE)<=" & CDbl(Emonthdate) & ")) " & _
"GROUP BY Ttable.Agent_Name, Ttable.Login_Id;"
On Error Resume Next
MyAccess.QueryDefs.Delete ("Temp1")
On Error GoTo 0
Set MyNewQuery = MyAccess.CreateQueryDef("Temp1", xSelect)
Set MyTemp = MyAccess.OpenRecordset("Temp1")
'**********Importing From Access**********
Sheets("Import").Select
Range("AST").Select
Selection.CopyFromRecordset MyTemp
MyAccess.QueryDefs.Delete ("Temp1")
|