- Katılım
- 2 Mart 2005
- Mesajlar
- 2,960
- Excel Vers. ve Dili
- ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
Kod:
Sub adbKset_Tarihler_Aç()
Set CSfData = CKtp_Bu.Sheets("DATA") 'Verilerin alınacağı sayfa.
Dim sqlFrom$, sqlBasl$, sqlSorg$, sqlSatr$, sqlGrup$
sqlBasl = "Tarihi, Aktif_Değeri, Reaktif_Değeri, Kapasitif_Değeri, Aciklama"
sqlGrup = "Sayac_No, Adi_Soyadi, Mevkii, Tarihi, Aktif_Değeri, Reaktif_Değeri, Kapasitif_Değeri, Aciklama"
sqlFrom = "[" & CSfData.Name & "$" & "A2:H1800" & "]"
sqlSorg = "Sayac_No = " & Me.ComboBox1.Column(0) 'Sayaç Numarası, Combobox1'e eşit olan kayıtlar
sqlSorg = sqlSorg & " AND UCase(Adi_Soyadi) Like '" & UCase(Me.TextBox1.Text) & "'" ' ve Adı soyadı, textbox1'i içeren kayıtlar
sqlSorg = sqlSorg & " AND Tarihi IS NOT NULL"
sqlSatr = "SELECT DISTINCT " & sqlBasl & " FROM " & sqlFrom & " WHERE " & sqlSorg
'sqlSatr = sqlSatr & " GROUP BY " & sqlGrup
sqlSatr = sqlSatr & " GROUP BY " & sqlGrup & " ORDER BY Tarihi DESC"
'ORDER BY UnitPrice DESC
' : sqlSatr : "SELECT DISTINCT Tarihi, Aktif_Değeri, Reaktif_Değeri, Kapasitif_Değeri, Aciklama FROM [DATA$A2:H1800] WHERE Sayac_No = 1582 AND UCase(Adi_Soyadi) Like 'AHMET ER' AND Tarihi IS NOT NUL"
'Adob RecordSet Sorgulaması
If Err = 0 Then
Set adbKset = CreateObject("ADODB.Recordset")
With adbKset
.ActiveConnection = adbBagl
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Source = sqlSatr
.Open
'***********************************************************************
ListBox1.Clear
Label15.Caption = Space(5) & .RecordCount & " Adet Okuma Kaydı bulundu"
If .RecordCount > 0 Then
[COLOR=SeaGreen] With ListBox1
.ColumnCount = adbKset.Fields.Count
.ColumnWidths = "60;60;60;60;100"
[B].Column = adbKset.GetRows[/B]
.TextAlign = fmTextAlignRight
' .SpecialEffect = fmSpecialEffectFlat
End With 'ListBox1[/COLOR]
End If
If CBool(.State And adStateOpen) = True Then .Close: Set adbKset = Nothing
End With
Else
MsgBox "Bağlantı Hatası Kontrol Ediniz", vbInformation, "Bilgi"
End If
With ListBox1
If .ListCount > 0 Then
For i = 0 To .ListCount - 1
[B][COLOR=Red] If .List(i, 0) <> "" Then .List(i, 0) = Format(.List(i, 0), "dd.mm.yyyy")
If .List(i, 1) <> "" Then .List(i, 1) = Format(.List(i, 1), "#,##0.0000")
If .List(i, 2) <> "" Then .List(i, 2) = Format(.List(i, 2), "#,##0.0000")
If .List(i, 3) <> "" Then .List(i, 3) = Format(.List(i, 3), "#,##0.0000")[/COLOR][/B]
Next i
End If
End With
End Sub
Kod:
...................
If adbKset.RecordCount > 0 Then
With CSfOzet
.Cells.Clear
.Range(.Cells(1, 1), .Cells(1, 3)).Value = Array("Sayac_No", "Adi_Soyadi", "Mevkii")
[B][COLOR=SeaGreen] .Range("a2").CopyFromRecordset adbKset[/COLOR][/B]
End With
'MsgBox "Kayıtlar Başarıyla Alındı.", vbInformation, "Bilgi"
Else
MsgBox "Kayıt Bulunamadı.", 16, "Bilgi"
End If
................
bu arada 1. koddaki sorgu sonucunu kımızı satırdakiler gibi formatlanmış olarak elde edebilirmiyiz?
Son düzenleme:
