Skip to main content

AccessTr.neT


İsimlerin Sayısını bulan SQL kodunu kısaltmak.

İsimlerin Sayısını bulan SQL kodunu kısaltmak.

Çözüldü #1
Aşağıdaki kod ile combobox1-2-3 teki süzme durumuna göre textbox1-2-3 e Ali-Veli-Ahmet isimlerinin sayılarını alrıyorum.Bu kod gittikçe uzuyor ve satır sayısı artıyor,bunu daha kestirme yoldan yapabilirmiyiz.
Kod:
Sub SAY()
If ComboBox1.Value <> "" And ComboBox2.Value = "" And ComboBox3.Value = "" Then
    TextBox1.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'ALİ'   and [CALISAN_KODU] like '" & ComboBox1.Value & "%'")(0)
    TextBox2.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'VELİ'  and [CALISAN_KODU] like '" & ComboBox1.Value & "%'")(0)
    TextBox3.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'AHMET' and [CALISAN_KODU] like '" & ComboBox1.Value & "%'")(0)
ElseIf ComboBox1.Value = "" And ComboBox2.Value <> "" And ComboBox3.Value = "" Then
    TextBox1.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'ALİ'   and [ADI] like '" & ComboBox2.Value & "%'")(0)
    TextBox2.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'VELİ'  and [ADI] like '" & ComboBox2.Value & "%'")(0)
    TextBox3.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'AHMET' and [ADI] like '" & ComboBox2.Value & "%'")(0)
ElseIf ComboBox1.Value = "" And ComboBox2.Value = "" And ComboBox3.Value <> "" Then
    TextBox1.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'ALİ'   and [DOGUM_TARIHI] like '" & ComboBox3.Value & "%'")(0)
    TextBox2.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'VELİ'  and [DOGUM_TARIHI] like '" & ComboBox3.Value & "%'")(0)
    TextBox3.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'AHMET' and [DOGUM_TARIHI] like '" & ComboBox3.Value & "%'")(0)
ElseIf ComboBox1.Value <> "" And ComboBox2.Value <> "" And ComboBox3.Value = "" Then
    TextBox1.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'ALİ'   and [CALISAN_KODU] like '" & ComboBox1.Value & "%'" & "and [ADI] like '" & ComboBox2.Value & "%'")(0)
    TextBox2.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'VELİ'  and [CALISAN_KODU] like '" & ComboBox1.Value & "%'" & "and [ADI] like '" & ComboBox2.Value & "%'")(0)
    TextBox3.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'AHMET' and [CALISAN_KODU] like '" & ComboBox1.Value & "%'" & "and [ADI] like '" & ComboBox2.Value & "%'")(0)
ElseIf ComboBox1.Value <> "" And ComboBox2.Value = "" And ComboBox3.Value <> "" Then
    TextBox1.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'ALİ'   and [CALISAN_KODU] like '" & ComboBox1.Value & "%'" & "and [DOGUM_TARIHI] like '" & ComboBox3.Value & "%'")(0)
    TextBox2.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'VELİ'  and [CALISAN_KODU] like '" & ComboBox1.Value & "%'" & "and [DOGUM_TARIHI] like '" & ComboBox3.Value & "%'")(0)
    TextBox3.Value = baglan.Execute("select count([ADI]) from [LİSTE] where [ADI] = 'AHMET' and [CALISAN_KODU] like '" & ComboBox1.Value & "%'" & "and [DOGUM_TARIHI] like '" & ComboBox3.Value & "%'")(0)

End If

End Sub

.rar EXCELDEN ACCESE VERİ AKTARMADA SAY KODUNUN KISALTILMASI.rar (Dosya Boyutu: 126 Bayt | İndirme Sayısı: 2)
Son Düzenleme: 12/01/2013, 15:17, Düzenleyen: alican60.
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da

Bu Konudaki Yorumlar
İsimlerin Sayısını bulan SQL kodunu kısaltmak. - Yazar: alican60 - 11/01/2013, 21:33
Task