hi guys, i want to use Dcount for count by multiple text box but when one textbox is null doesn't find any record, and i have to use alot of if and elseif for this purpose, for example i wrote Multiple elseif tow textbox :
If Not IsNull(Me.Text4) And Not IsNull(Me.Text6) Then
x = DCount("ID", "tbl_Patients", "[P_Sex]= '" & Me.Text4 & "' and [P_Status]= '" & Me.Text6 & "'")
ElseIf Not IsNull(Me.Text4) And IsNull(Me.Text6) Then
x = DCount("ID", "tbl_Patients", "[P_Sex]= '" & Me.Text4 & "'")
ElseIf IsNull(Me.Text4) And Not IsNull(Me.Text6) Then
x = DCount("ID", "tbl_Patients", "[P_Status]= '" & Me.Text6 & "'")
ElseIf IsNull(Me.Text4) And IsNull(Me.Text6) Then
x = DCount("ID", "tbl_Patients")
End If
MsgBox x
,,,,,,,,,,
for this problem i try to use Nz function for doesn't consider null textbox as below code :
x = DCount("ID", "tbl_Patients", "[P_Sex]= '" & Nz(Me.Text4, "") & "' and [P_Status]= '" & Nz(Me.Text6, "") & "'")
but it's not working again
is there any better solution?? (i have to do this without querry)
thanks in advanced and sorry for my poor english