AccessTr.neT
Lıke Operatörü - Baskı Önizleme

+- AccessTr.neT (https://accesstr.net)
+-- Forum: Microsoft Access (https://accesstr.net/forum-microsoft-access.html)
+--- Forum: Access Cevaplanmış Soruları (https://accesstr.net/forum-access-cevaplanmis-sorulari.html)
+--- Konu Başlığı: Lıke Operatörü (/konu-like-operatoru.html)

Sayfalar: 1 2 3


RE: Lıke Operatörü - H@K@N - 24/03/2022

(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.


Re: Lıke Operatörü - berduş - 24/03/2022

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



RE: Lıke Operatörü - H@K@N - 25/03/2022

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