ragnorak
Altın Üye
- Katılım
- 4 Haziran 2016
- Mesajlar
- 208
- Excel Vers. ve Dili
- Excel 2021
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Private Sub UserForm_Activate()
Dim Con As Object, Rs As Object, Sorgu As String
Set Con = CreateObject("Adodb.Connection")
Con.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & ThisWorkbook.Path & "\Database1.accdb" & ";"
Set Rs = CreateObject("Adodb.RecordSet")
Sorgu = "SELECT [ÜST KENAR MALZEMESİ],[ÜST KENAR KALINLIĞI], format(SUM(([GENİŞLİK]+[PAY GENİŞLİK])*[MİKTAR]/1000), '#,##0.00') as TOPLAM from [PANEL] where not isnull([ÜST KENAR MALZEMESİ]) and [ÜST KENAR MALZEMESİ] <> '' GROUP BY [ÜST KENAR MALZEMESİ],[ÜST KENAR KALINLIĞI]" _
& " union all SELECT [ALT KENAR MALZEMESİ],[ALT KENAR KALINLIĞI], format(SUM(([GENİŞLİK]+[PAY GENİŞLİK])*[MİKTAR]/1000), '#,##0.00') as TOPLAM from [PANEL] where not isnull([ALT KENAR MALZEMESİ]) and [ALT KENAR MALZEMESİ] <> '' GROUP BY [ALT KENAR MALZEMESİ],[ALT KENAR KALINLIĞI]" _
& " union all SELECT [SOL KENAR MALZEMESİ],[SOL KENAR KALINLIĞI], format(SUM(([YÜKSEKLİK]+[PAY YÜKSEKLİK])*[MİKTAR]/1000), '#,##0.00') as TOPLAM from [PANEL] where not isnull([SOL KENAR MALZEMESİ]) and [SOL KENAR MALZEMESİ] <> '' GROUP BY [SOL KENAR MALZEMESİ],[SOL KENAR KALINLIĞI]" _
& " union all SELECT [SAĞ KENAR MALZEMESİ],[SAĞ KENAR KALINLIĞI], format(SUM(([YÜKSEKLİK]+[PAY YÜKSEKLİK])*[MİKTAR]/1000), '#,##0.00') as TOPLAM from [PANEL] where not isnull([SAĞ KENAR MALZEMESİ]) and [SAĞ KENAR MALZEMESİ] <> '' GROUP BY [SAĞ KENAR MALZEMESİ],[SAĞ KENAR KALINLIĞI]"
Rs.Open Sorgu, Con, 1, 3
ListBox1.ColumnCount = Rs.Fields.Count
ListBox1.Column = Rs.getrows
Rs.Close
Con.Close
Set Con = Nothing
Set Rs = Nothing
End Sub

Sub analiz_1()
Dim wsh As Object
Set wsh = CreateObject("WScript.Shell")
kx = wsh.RegRead("HKCU\Win\Win\030d") 'KENARBANDI FİRE
If kx = "" Then: kx = 0
Call Ado_Baglan
Set RS = CreateObject("adodb.recordset")
Set RS1 = CreateObject("adodb.recordset")
Sorgu = "SELECT [MALZEME],[KALINLIK], format(SUM([ALAN]), '#,##0.000') as TOPLAM from [PANEL] where not isnull([MALZEME]) GROUP BY [MALZEME],[KALINLIK]" _
& "union all SELECT [ÜST KENAR MALZEMESİ],[ÜST KENAR KALINLIĞI], format(SUM(([GENİŞLİK]+" & kx & "*2)*[MİKTAR]/1000), '#,##0.00') as TOPLAM from [PANEL] where not isnull([ÜST KENAR MALZEMESİ]) and [ÜST KENAR MALZEMESİ] <> '' GROUP BY [ÜST KENAR MALZEMESİ],[ÜST KENAR KALINLIĞI]" _
& "union all SELECT [ALT KENAR MALZEMESİ],[ALT KENAR KALINLIĞI], format(SUM(([GENİŞLİK]+" & kx & "*2)*[MİKTAR]/1000), '#,##0.00') as TOPLAM from [PANEL] where not isnull([ALT KENAR MALZEMESİ]) and [ALT KENAR MALZEMESİ] <> '' GROUP BY [ALT KENAR MALZEMESİ],[ALT KENAR KALINLIĞI]" _
& "union all SELECT [SOL KENAR MALZEMESİ],[SOL KENAR KALINLIĞI], format(SUM(([YÜKSEKLİK]+" & kx & "*2)*[MİKTAR]/1000), '#,##0.00') as TOPLAM from [PANEL] where not isnull([SOL KENAR MALZEMESİ]) and [SOL KENAR MALZEMESİ] <> '' GROUP BY [SOL KENAR MALZEMESİ],[SOL KENAR KALINLIĞI]" _
& "union all SELECT [SAĞ KENAR MALZEMESİ],[SAĞ KENAR KALINLIĞI], format(SUM(([YÜKSEKLİK]+" & kx & "*2)*[MİKTAR]/1000), '#,##0.00') as TOPLAM from [PANEL] where not isnull([SAĞ KENAR MALZEMESİ]) and [SAĞ KENAR MALZEMESİ] <> '' GROUP BY [SAĞ KENAR MALZEMESİ],[SAĞ KENAR KALINLIĞI]"
RS.Open Sorgu, con, 1, 3
If RS.RecordCount <= 0 Then: XED_FORM.StatusBar1.Panels.Item(1) = "Listede Kayıt Bulunmuyor!": Beep: GoTo devam: Exit Sub
'.................................................................................................................................. ACCESS PP YE YAZIYORUZ
Sorgu1 = "SELECT * from [PP]"
RS1.Open Sorgu1, con, 1, 3
Do While Not RS.EOF
RS1.addnew
RS1.Fields("ALAN_1").Value = RS.Fields(0).Value & "," & RS.Fields(1).Value
RS1.Fields("ALAN_2").Value = RS.Fields(2).Value
RS1.Update
RS.MoveNext
Loop
RS.Close: RS1.Close: Sorgu = "": Sorgu1 = ""
'.................................................................................................................................. LİSTVİEW YAZIYORUZ
Sorgu = "SELECT [ALAN_1], format(SUM([ALAN_2]), '#,##0.000') as TOPLAM from [PP] where not isnull([ALAN_1]) GROUP BY [ALAN_1]"
RS.Open Sorgu, con, 1, 3
With Me.ListView1
.View = lvwReport
.FullRowSelect = True
.ListItems.Clear
.ColumnHeaders.Clear
.ColumnHeaders.Add , , "ID"
.ColumnHeaders.Add , , "MALZEME"
.ColumnHeaders.Add , , "TOPLAM"
.ColumnHeaders(1).Width = 37
.ColumnHeaders(2).Width = 250
.ColumnHeaders(3).Width = 100
.ColumnHeaders(2).Alignment = lvwColumnLeft
.ColumnHeaders(3).Alignment = lvwColumnRight
a = 1
Do While Not RS.EOF
.ListItems.Add , , a
.ListItems.Item(a).ListSubItems.Add , , RS.Fields(0).Value
.ListItems.Item(a).ListSubItems.Add , , RS.Fields(1).Value
.ListItems(a).ListSubItems(2).ForeColor = XED_FORM.Image25.BackColor
a = a + 1
RS.MoveNext
Loop
End With
devam:
RS.Close: con.Close
Set con = Nothing: Set RS = Nothing: Sorgu = ""
End Sub
Sorgu = "select [ÜST KENAR MALZEMESİ],[ÜST KENAR KALINLIĞI] , SUM(TOPLAM) from (" & Sorgu & ") group by [ÜST KENAR MALZEMESİ],[ÜST KENAR KALINLIĞI] "
Sorgu = " Select [Malzeme], Format(Sum(Toplam), '#,##0.00') " _
& " From " _
& " (" _
& " Select [ÜST KENAR MALZEMESİ] As [Malzeme], Sum(([GENİŞLİK]+[PAY GENİŞLİK])*[MİKTAR]/1000) as [Toplam] from [PANEL] GROUP BY [ÜST KENAR MALZEMESİ] " _
& " Union All Select [ALT KENAR MALZEMESİ], Sum(([GENİŞLİK]+[PAY GENİŞLİK])*[MİKTAR]/1000) from [PANEL] GROUP BY [ALT KENAR MALZEMESİ] " _
& " Union All Select [SOL KENAR MALZEMESİ], Sum(([YÜKSEKLİK]+[PAY YÜKSEKLİK])*[MİKTAR]/1000) from [PANEL] GROUP BY [SOL KENAR MALZEMESİ] " _
& " Union All Select [SAĞ KENAR MALZEMESİ], Sum(([YÜKSEKLİK]+[PAY YÜKSEKLİK])*[MİKTAR]/1000) from [PANEL] GROUP BY [SAĞ KENAR MALZEMESİ] " _
& " )" _
& " Where [Malzeme] <>'' Group By [Malzeme]"