Skip to main content

AccessTr.neT


Lıke Operatörü

Lıke Operatörü

#13
(24/03/2022, 16:40)berduş yazdı: Sadece başlangıcı mi uyacak?
Kod:
If Len(Trim(TextBox3.Value & vbNullString)) > 0 Then
strSorgu = strSorgu & " AND personel.ad='" & TextBox3.Text & "'"
Else
strSorgu = strSorgu & " AND personel.ad LIKE '" & TextBox3.Text & "%'"
End If

yerine
Kod:
If Len(Trim(TextBox3.Value & vbNullString)) > 0 Then strSorgu = strSorgu & " AND personel.ad LIKE '" & textBox3.Text & "%'"
yazarak dener misiniz



Üstad olmadı yine Img-cray


.... ile başlayan her kaydı getir.
Son Düzenleme: 24/03/2022, 16:56, Düzenleyen: H@K@N.
Cevapla
#14
ara butonunun kodunu aşağıdaki gibi düzenleyip dener misiniz?
Dim baglan As New Connection
Dim rs As New Recordset

baglan.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\master.accdb;"
strSorgu = "select * from [personel] WHERE personel.id > 0"
    If Len(Trim(ComboBox1.Value & vbNullString)) > 0 Then strSorgu = strSorgu & " AND personel.cinsiyet LIKE '" & ComboBox1.Text & "%'"
    If Len(Trim(TextBox2.Value & vbNullString)) > 0 Then strSorgu = strSorgu & " AND personel.tckn LIKE '" & TextBox2.Text & "%'"
    If Len(Trim(TextBox3.Value & vbNullString)) > 0 Then strSorgu = strSorgu & " AND personel.ad LIKE '" & TextBox3.Text & "%'"
    If Len(Trim(TextBox4.Value & vbNullString)) > 0 Then strSorgu = strSorgu & " AND personel.soyad LIKE '" & TextBox4.Text & "%'"
   
rs.Open strSorgu, baglan, adOpenKeyset, adLockPessimistic
ListBox1.ColumnCount = rs.Fields.Count
If rs.RecordCount <> 0 Then ListBox1.Column = rs.GetRows Else ListBox1.Clear
rs.Close
baglan.Close
Cevapla
#15
Aşağıdaki kod ile sorun çözülmüştür.


If Len(Trim(TextBox1.Value & vbNullString)) > 0 Then
strSorgu = strSorgu & " AND personel.sicilno LIKE '" & TextBox1.Text & "%'"
End If

AÇIKLAMA:
------------

If Len(Trim(TextBox3.Value & vbNullString)) > 0 Then

Bu kod textbox dolu ise
strSorgu = strSorgu & " AND personel.ad='" & TextBox3.Text & "'"

Else

Bu kod textbox dolu değil ise
strSorgu = strSorgu & " AND personel.ad LIKE '" & TextBox3.Text & "%'"

End If

Kod aşağıdaki gibi değiştirildi.

If Len(Trim(TextBox3.Value & vbNullString)) > 0 Then
strSorgu = strSorgu & " AND personel.ad LIKE '" & TextBox3.Text & "%'"
End If
Cevapla

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

Yorum yapmak için üye olmanız gerekiyor

ya da
Task