SCMON Access SQL Pivot

Dassudt

New Member
Joined
May 7, 2017
Messages
16
Sub SQLtest()
Dim Dbe As DAO.Database
Dim Qr As DAO.QueryDef
Dim qdfTRANSFORM As DAO.Database
Dim pSQL1 As String

Set Db = CurrentDb
DoCmd.TransferText TransferType:=acImportDelim, TableName:="Dept1", _
FileName:="C:\Users\Sindhu\Desktop\SC\Dept1.Txt", HasFieldNames:=True
pSQL1 = "TRANSFORM Sum(Amount) as TGeek SELECT Hospital, SUM(Amount) as Total FROM GeeK Group BY Hospital PIVOT COBID IN (COB, CODD, COI)"
pSQL1 = "Select Emp1.EmpName, Dept1.DeptNo FROM Emp1 INNER JOIN Dept1 ON Emp1.DeptID=Dept1.DeptID"
End Sub


Team i found code error in the above statement, kindly help me.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Sub DeskBezTest()
Application.ScreenUpdating = False
FilenameDz = Application.GetOpenFilename("Text Files (*.csv), *.csv")
Workbooks.OpenText (FilenameDz)
Path = ActiveWorkbook.Path
Set Wb = ActiveWorkbook
Columns("B:B").Select
Selection.Copy
Columns("F:F").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveSheet.Range("F:F").RemoveDuplicates Columns:=1, Header:=xlNo

lrow = Range("F" & Rows.Count).End(xlUp).Row

For i = 2 To lrow
Wb.Activate
SearchName = ActiveSheet.Range("F" & i).Value
ActiveSheet.Range("A:B").AutoFilter Field:=2, Criteria1:=SearchName
Columns("A:B").Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Paste
ActiveSheet.Name = SearchName
Range("a1").Select
Sheets("Desk.Bez").Activate
Next i
Application.CutCopyMode = True
ActiveSheet.AutoFilterMode = False
Sheets("Desk.Bez").Range("F:F").ClearContents
Range("a1").Select

ActiveWorkbook.SaveAs Replace(ActiveWorkbook.FullName, ".csv", ".xls"), FileFormat:=xlExcel8
ActiveWorkbook.Close True
Application.DisplayAlerts = False
Application.ScreenUpdating = False
End Sub
 
Upvote 0
You second post seems to have absolutely nothing to do with your first. It actually seems to be Excel code.
Was it posted in error?
 
Upvote 0

Forum statistics

Threads
1,221,692
Messages
6,161,351
Members
451,697
Latest member
pedroDH

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