• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

ado

  • Konbuyu başlatan Konbuyu başlatan tahh_74
  • Başlangıç tarihi Başlangıç tarihi
Katılım
2 Eylül 2004
Mesajlar
50
Merhaba,

access database'inde bulunan tüm dataları Sheet üzerindeki listbox'a taşıyan bir excel makrosu yazdım ama listbox'da data seçtiğimde seçtiğim satırın sütun değerlerinin textbox'lara yazılmasını istiyorum ama ekteki hatayı alıyorum sorunu bir türlü çözemedim.yardımlarınız için şimdiden teşekkürler

Ahmet
 
Listbgoxtan textboxa değerleri aktardığınız kodları yazarmısınız.
 
Sub ListBox_gir()
Set RS = CreateObject("ADODB.recordset")
strSQL = "SELECT * FROM [MyTable] where cihazno= '" & sheet1.ListBox1.Select & "'"
RS.Open strSQL, adoCN, 1, 3
sheet1.TextBox1 = RS("cihazno")
sheet1.TextBox2 = RS("arizasikayet")
sheet1.TextBox3 = RS("cozumyolu")
sheet1.TextBox4 = RS("not")
sheet1.TextBox5 = RS("ekler")
sheet1.TextBox6 = RS("giren")
Set RS = Nothing
End Sub
'
 
Aşağıdaki gibi denermisiniz.

[vb:1:ead1613f3c]Sub ListBox_gir()
Set RS = CreateObject("ADODB.recordset")
strSQL = "SELECT * FROM [MyTable] where cihazno= '" & sheet1.ListBox1.Select & "'"
sheet1.TextBox1 = sheet1.ListBox1.column(0)
sheet1.TextBox2 = sheet1.ListBox1.column(1)
sheet1.TextBox3 = sheet1.ListBox1.column(2)
sheet1.TextBox4 = sheet1.ListBox1.column(3)
sheet1.TextBox5 = sheet1.ListBox1.column(4)
sheet1.TextBox6 = sheet1.ListBox1.column(5)
End Sub
[/vb:1:ead1613f3c]
 
Bu hata listboxtaki sütun nolarının hatalı olduğunu gösterir. Listboxunuzda kaç kolon mevcut.
 
sheet1.TextBox1 = sheet1.ListBox1.column(0)

Yukarıdaki satırı iptal ederek denermisiniz.
 
sheet1.TextBox1 = sheet1.ListBox1.column(0)
sheet1.TextBox2 = sheet1.ListBox1.column(1)
sheet1.TextBox3 = sheet1.ListBox1.column(2)
sheet1.TextBox4 = sheet1.ListBox1.column(3)
sheet1.TextBox5 = sheet1.ListBox1.column(4)
sheet1.TextBox6 = sheet1.ListBox1.column(5)

Yukarıdaki satırları iptal edin ve 0 dan başlamak üzere tek tek aktif hale getirerek deneyin.
 
Yukarıdaki kodları mevcut prosedürden silip aşağıdaki gibi listboxun click olayına yazarak deneyin.

[vb:1:cb658d974c]Private Sub ListBox1_Click()
sheet1.TextBox1 = sheet1.ListBox1.column(0)
sheet1.TextBox2 = sheet1.ListBox1.column(1)
sheet1.TextBox3 = sheet1.ListBox1.column(2)
sheet1.TextBox4 = sheet1.ListBox1.column(3)
sheet1.TextBox5 = sheet1.ListBox1.column(4)
sheet1.TextBox6 = sheet1.ListBox1.column(5)
End Sub
[/vb:1:cb658d974c]
 
Geri
Üst