-
Hey there
I have ammeneded the code and think it will work but it gives me an error Run Time Error 13 a data type mismatch...
[VBA]Sub GetData()
'You have to set a reference to
'microsoft dao 3.6 object library
'Tested under excel 2003
Dim Db As Database
Dim Rs As Recordset
Dim Ws As Object
Dim i As Long
Dim MyPath As String
Set Ws = Worksheets(2)
'Set the Path to the database. This line is useful because
'if your database is in another location, you just need to change
'it here and the Path Variable will be used throughout the code
MyPath = "C:\Documents and Settings\Russell\Desktop\Database Info\Sales Telly Store.mdb"
'This set of code will activate Sheet3 and clear any existing data
'After clearing the data it will select cell A1
Ws.Activate
Range("A1").Activate
Selection.CurrentRegion.Select
Selection.ClearContents
Range("A1").Select
'Set the Database, and RecordSet This Table exists in the database
Set Db = Workspaces(0).OpenDatabase(MyPath, ReadOnly:=True)
sSQL = "SELECT" * "Data.TellyTeam, Count(Data.AgtCode) AS CountOfAgtCode FROM Data GROUP BY Data.TellyTeam;"
sSQL = "SELECT Data.TellyTeam, Count(Data.[NQ/Cat]) AS [CountOfNQ/Cat] FROM Data WHERE (([Data]![NQ/Cat] = Qual Or (Data.[NQ/Cat]) = QWOS Or (Data.[NQ/Cat]) = OF))GROUP BY Data.TellyTeam ORDER BY Data.TellyTeam;"
sSQL = "SELECT Data.TellyTeam, Count(Data.AgtCode) AS CountOfAgtCode FROM Data GROUP BY Data.TellyTeam;"
sSQL = "SELECT Data.TellyTeam, Count(Data.Sale) AS CountOfSale FROM Data WHERE ((([Data]![Sale]) = Y)) GROUP BY Data.TellyTeam;"
sSQL = "SELECT Data.TellyTeam, Count(Data.ConfCode) AS CountOfConfCode FROM Data GROUP BY Data.TellyTeam;"
sSQL = "SELECT Data.TellyTeam, Count(Data.TellyTeam) AS CountOfTellyTeam FROM Data GROUP BY Data.TellyTeam;"
'This next code set will just select the data region and
'auto-fit the columns
Ws.Range("A1").Select
Selection.CurrentRegion.Select
Selection.Columns.AutoFit
Ws.Range("A1").Select
Rs.Close
Db.Close
End Sub
[/VBA]
Please help....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules