73
ห้อง MS Access / : กรองข้อมูลด้วย Combo Box และ Check Box และการค้นหาข้อมูลที่กรองยังไงครับ
« เมื่อ: 01 ต.ค. 62 , 20:01:51 »
ผมขอเสนอวิธีเขียนโค้ดที่รวม 2 เงื่อนไขด้วย AND แบบสั้นๆ
Dim Cond1 As String, Cond2 As String
If Nz(Me.combonamesearch,"") = "" Then Cond1 = " TRUE " Else Cond1 = " ([cus_name] = '" & Me.combonamesearch & "') "
If Nz([acculate],"") = "" Then Cond2 = " TRUE " Else Cond2 = " ([acculate] = " & Me.acculatesearch & ") "
Forms!frmhistoryh!frmhistorylist.Form.RecordSource = "select * from Qsaleh_cusprof where " & Cond1 & " AND " & Cond2
Dim Cond1 As String, Cond2 As String
If Nz(Me.combonamesearch,"") = "" Then Cond1 = " TRUE " Else Cond1 = " ([cus_name] = '" & Me.combonamesearch & "') "
If Nz([acculate],"") = "" Then Cond2 = " TRUE " Else Cond2 = " ([acculate] = " & Me.acculatesearch & ") "
Forms!frmhistoryh!frmhistorylist.Form.RecordSource = "select * from Qsaleh_cusprof where " & Cond1 & " AND " & Cond2
โพสต์นี้ได้รับคำขอบคุณจาก: PNR