11/01/2013, 21:33
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