Private Sub Command20_Click()
On Error GoTo Err_Command20_Click
'Button filters out records depending on the criteria entered in the search fields
Dim strWhere As String
Dim lngLen As Long
'Stores the search criteria and enters it into the Where Condition - Log Reference
If Not IsNull([Forms]![frmBase]![chdDetail].[Form]![fldLogRef]) Then
strWhere = "([fldLogRef] = [Forms]![frmBase]![chdDetail].[Form]![fldLogRef]) And "
End If
'Stores the search criteria and enters it into the Where Condition - Country
If Not IsNull([Forms]![frmBase]![chdDetail].[Form]![fldCountry]) Then
strWhere = "( [fldCountry] = [Forms]![frmBase]![chdDetail].[Form]![fldCountry]) AND " & strWhere
End If
'Stores the search criteria and enters it into the Where Condition - Date Requested
If Not IsNull([Forms]![frmBase]![chdDetail].[Form]![fldRequestDate]) Then
strWhere = "( [fldRequestDate] = [Forms]![frmBase]![chdDetail].[Form]![fldRequestDate]) AND " & strWhere
End If
'Stores the search criteria and enters it into the Where Condition - Description
If Not IsNull([Forms]![frmBase]![chdDetail].[Form]![fldDescription]) Then
strWhere = "( [fldDescription] = [Forms]![frmBase]![chdDetail].[Form]![fldDescription]) AND " & strWhere
End If
'Stores the search criteria and enters it into the Where Condition - Status
If Not IsNull([Forms]![frmBase]![chdDetail].[Form]![fldStatus]) Then
strWhere = "( [fldStatus] = [Forms]![frmBase]![chdDetail].[Form]![fldStatus]) AND " & strWhere
End If
'Stores the search criteria and enters it into the Where Condition - Date Shipped
If Not IsNull([Forms]![frmBase]![chdDetail].[Form]![fldShipDate]) Then
strWhere = "( [fldShipDate] = [Forms]![frmBase]![chdDetail].[Form]![fldShipDate]) AND " & strWhere
End If
'Stores the search criteria and enters it into the Where Condition - Tracking #
If Not IsNull([Forms]![frmBase]![chdDetail].[Form]![fldTrack]) Then
strWhere = "( [fldTrack] = [Forms]![frmBase]![chdDetail].[Form]![fldtrack]) AND " & strWhere
End If
lngLen = Len(strWhere) - 5
'If there was no information included in the criteria fields an error pops up, otherwise the search processes the Where Condition
If lngLen <= 0 Then
MsgBox "Please enter search criteria!"
Else
strWhere = Left$(strWhere, lngLen)
Forms!frmBase!chdList.Form.List0.RowSource = strWhere
End If
'Reverses Any Edits
Me.Undo
Exit_Command20_Click:
Exit Sub
Err_Command20_Click:
MsgBox Err.Description
Resume Exit_Command20_Click
End Sub