25/08/2020, 13:02
Function GrafikKaynak(TabloAdi As String, AyAdi As String, GrafAdi As String)
connection_open
sql1 = "select * from " & TabloAdi & " where format(tarih,'m.yyyy')='" & AyAdi & "';"
rsGrf.Open sql1, conn, adOpenKeyset, adLockPessimistic
Worksheets(TabloAdi).Cells.Clear
Worksheets(TabloAdi).Range("A1").CopyFromRecordset rsGrf
'debug.print "rsGrf.Fields.Count", rsGrf.Fields.Count
Dim AlanSay As Integer
For AlanSay = 1 To rsGrf.Fields.Count
'debug.print "rsGrf(AlanSay - 1).Name : ", AlanSay, rsGrf(AlanSay - 1).Name
Worksheets(TabloAdi).Cells(1, AlanSay).Value = rsGrf(AlanSay - 1).Name
Next AlanSay
Worksheets(TabloAdi).Range("A2").CopyFromRecordset rsGrf
'hy ListView veri ekle
With grafik.ListView1
For i = 0 To rsGrf.Fields.Count - 1
.ColumnHeaders.Add , , rsGrf.Fields(i).Name
Next i
End With
If rsGrf.RecordCount > 0 Then rsGrf.MoveFirst
Dim lw_rec As ListItem
With grafik.ListView1
.ListItems.Clear
Do While Not rsGrf.EOF
Set lw_rec = .ListItems.Add(, , rsGrf.Fields(0).Value)
For X = 1 To rsGrf.Fields.Count - 1
lw_rec.SubItems(X) = IIf(IsNull(rsGrf.Fields(X).Value), "0", rsGrf.Fields(X).Value)
Next X
rsGrf.MoveNext
Loop
.FullRowSelect = True
.Gridlines = True
.View = lvwReport
End With
rsGrf.Close
conn.Close
'hy UserForm Grafik ekleme________________________
Dim sTempFile As String
Dim sChartName As String
Dim oChart As Chart
'BARAJ KOTU DEĞİŞİM GRAFİĞİ
sTempFile = Environ("temp") & "\temp.gif"
Debug.Print GrafAdi
Set oChart = Worksheets("örnekgrafik").ChartObjects(CStr(GrafAdi)).Chart
oChart.Export Filename:=sTempFile, FilterName:="GIF"
grafik.Image3.Picture = LoadPicture(sTempFile)
Kill sTempFile
MsgBox "bitti"
End Function
Kalın punto ile yazılan yerde butona bastığımda hata alıyorum sürekli
connection_open
sql1 = "select * from " & TabloAdi & " where format(tarih,'m.yyyy')='" & AyAdi & "';"
rsGrf.Open sql1, conn, adOpenKeyset, adLockPessimistic
Worksheets(TabloAdi).Cells.Clear
Worksheets(TabloAdi).Range("A1").CopyFromRecordset rsGrf
'debug.print "rsGrf.Fields.Count", rsGrf.Fields.Count
Dim AlanSay As Integer
For AlanSay = 1 To rsGrf.Fields.Count
'debug.print "rsGrf(AlanSay - 1).Name : ", AlanSay, rsGrf(AlanSay - 1).Name
Worksheets(TabloAdi).Cells(1, AlanSay).Value = rsGrf(AlanSay - 1).Name
Next AlanSay
Worksheets(TabloAdi).Range("A2").CopyFromRecordset rsGrf
'hy ListView veri ekle
With grafik.ListView1
For i = 0 To rsGrf.Fields.Count - 1
.ColumnHeaders.Add , , rsGrf.Fields(i).Name
Next i
End With
If rsGrf.RecordCount > 0 Then rsGrf.MoveFirst
Dim lw_rec As ListItem
With grafik.ListView1
.ListItems.Clear
Do While Not rsGrf.EOF
Set lw_rec = .ListItems.Add(, , rsGrf.Fields(0).Value)
For X = 1 To rsGrf.Fields.Count - 1
lw_rec.SubItems(X) = IIf(IsNull(rsGrf.Fields(X).Value), "0", rsGrf.Fields(X).Value)
Next X
rsGrf.MoveNext
Loop
.FullRowSelect = True
.Gridlines = True
.View = lvwReport
End With
rsGrf.Close
conn.Close
'hy UserForm Grafik ekleme________________________
Dim sTempFile As String
Dim sChartName As String
Dim oChart As Chart
'BARAJ KOTU DEĞİŞİM GRAFİĞİ
sTempFile = Environ("temp") & "\temp.gif"
Debug.Print GrafAdi
Set oChart = Worksheets("örnekgrafik").ChartObjects(CStr(GrafAdi)).Chart
oChart.Export Filename:=sTempFile, FilterName:="GIF"
grafik.Image3.Picture = LoadPicture(sTempFile)
Kill sTempFile
MsgBox "bitti"
End Function
Kalın punto ile yazılan yerde butona bastığımda hata alıyorum sürekli