khanhduycsgt > 24-06-12, 07:45 PM
Dim s, s1, s2, s3, s4, s5 As String 'Khai bao cac bien chua thong tin
'Day la dong lenh SQL de apply cho lstDANHSACH.rowsource:
s = "SELECT tblTHONGTIN.MaCB, tblTHONGTIN.Hovaten, tblTHONGTIN.Ngaysinh, tblTHONGTIN.Quequan, tblTHONGTIN.Dantoc FROM tblTHONGTIN WHERE (1=1"
'Day la cac phan mo rong de chen vao sau doan SQL tren:
s1 = " AND ((tblTHONGTIN.MaCB) = " & [txtMaCB] & ")"
s2 = " AND ((tblTHONGTIN.Hovaten) like '" & "*" & [txtHovaten] & "*" & "')"
s3 = " AND ((tblTHONGTIN.Ngaysinh)=" & [txtNgaysinh & ")"
s4 = " AND ((tblTHONGTIN.Quequan) like '" & "*" & [txtQuequan] & "*" & "')"
s5 = " AND ((tblTHONGTIN.Dantoc)=" & Me.txtDantoc & ")"
'Cu moi textbox co du lieu thi se chen dieu kien loc vao doan SQL tren:
If IsNull(Trim(txtMaCB)) = False Then
s = s + s1
End If
If IsNull(Trim(txtHovaten)) = False Then
s = s + s2
End If
If IsNull(Trim(txtNgaysinh)) = False Then
s = s + s3
End If
If IsNull(Trim(txtQuequan)) = False Then
s = s + s4
End If
If IsNull(Trim(txtDantoc)) = False Then
s = s + s5
End If
'Chen them phan duoi ket thuc cu phap lenh SQL tren:
Me.lstDANHSACH.RowSource = s & ") ORDER BY tblTHONGTIN.MaCB; "
Me.lstDANHSACH.Requery
uronmapu > 24-06-12, 07:51 PM
khanhduycsgt > 24-06-12, 07:53 PM
phongld > 12-07-12, 03:14 PM
khanhduycsgt > 04-08-12, 11:01 AM
pmt007 > 30-09-12, 09:34 PM
cpucloi > 02-10-12, 09:29 PM
khactiep > 21-04-13, 10:05 PM
huyvu333 > 10-04-14, 08:26 PM
duyetnc > 12-04-14, 07:14 PM