Hi.. I have this code which I copied from other tutorials.... but I really don't know what's wrong with my date "From" & "End" query.. it's not giving the right results. Please help.. Thanks.
 
 
Private Sub openpqrprt_click()
On Error GoTo err_openpqrprt_click
Dim stdocname As String
stdocname = "RprtP&QID"
Dim whereclause As String
    
If Not IsNull(txtmep) Then
whereclause = "[MEPNumber]='" & txtmep & ""
End If
    
If Not IsNull(txtPfromDate) Then
If whereclause <> "" Then whereclause = whereclause & "AND"
whereclause = whereclause & "[PassportExpiryDate]>=#" & Format(txtPfromDate, "mm/dd/yyy") & "#"
End If
    
If Not IsNull(txtPEndDate) Then
If whereclause <> "" Then whereclause = whereclause & "AND"
whereclause = whereclause & "[PassportExpiryDate]<=#" & Format(txtPEndDate, "mm/dd/yyy") & "#"
End If
    
    
DoCmd.openreport stdocname, acPreview, , whereclause
    
Exit_openpqrprt_click:
Exit Sub
    
err_openpqrprt_click:
MsgBox Err.Description
Resume Exit_openpqrprt_click
        
    
    
    
End Sub
 Private Sub openpqrprt_click()
On Error GoTo err_openpqrprt_click
Dim stdocname As String
stdocname = "RprtP&QID"
Dim whereclause As String
If Not IsNull(txtmep) Then
whereclause = "[MEPNumber]='" & txtmep & ""
End If
If Not IsNull(txtPfromDate) Then
If whereclause <> "" Then whereclause = whereclause & "AND"
whereclause = whereclause & "[PassportExpiryDate]>=#" & Format(txtPfromDate, "mm/dd/yyy") & "#"
End If
If Not IsNull(txtPEndDate) Then
If whereclause <> "" Then whereclause = whereclause & "AND"
whereclause = whereclause & "[PassportExpiryDate]<=#" & Format(txtPEndDate, "mm/dd/yyy") & "#"
End If
DoCmd.openreport stdocname, acPreview, , whereclause
Exit_openpqrprt_click:
Exit Sub
err_openpqrprt_click:
MsgBox Err.Description
Resume Exit_openpqrprt_click
End Sub