adodb sorgusundan gelen comboda ilk değeri seçme hk.

Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
aşağıdaki kodlar ile adob sorgusunu comboya alıyorum.
yalnız 3 sütun gedliği için direkt value deyince hata veriyor ne önerebilirsiniz.
Kod:
Private Sub adbKset_İsimler_Aç()
  Set CSfData = CKtp_Bu.Sheets("DATA")     'Verilerin alınacağı sayfa.
  Dim sqlFrom$, sqlSorg$, sqlSatr$

  'Adob RecordSet Değişkenleri
  sqlFrom = "[" & CSfData.Name & "$" & "A2:C1800" & "]"
  sqlSorg = "Sayac_No IS NOT NULL"
  sqlSatr = "SELECT DISTINCT * FROM " & sqlFrom & " WHERE " & sqlSorg

  '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
      '***********************************************************************
      ComboBox1.Clear
      If .RecordCount > 0 Then
[B][COLOR=Red]        ComboBox1.ColumnCount = .Fields.Count
        ComboBox1.Column = .GetRows
'        ComboBox1.Value = ComboBox1.List(0, 0)[/COLOR][/B]
      Else
        MsgBox "İsme ait Kayıt Bulunamadı.", 16, "Bilgi"
      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
End Sub
 
Katılım
15 Haziran 2006
Mesajlar
3,704
Excel Vers. ve Dili
Excel 2003, 2007, 2010 (TR)
İlk elemanı seçmek için ...

Kod:
If ComboBox1.ListCount > 0 Then ComboBox1.ListIndex = 0
kodunu kullanın ...
 
Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
teşekkür ederim hocam.
 
Üst