Private Function Search_OrderList_SQL(Optional Criteria As String = "")
Dim dteTEMP As Date
Dim strRowSource As String
Dim strSearchFor As String
Dim WHERE As String
Dim adoConn As ADODB.Connection
Dim adoCmd As ADODB.Command
Dim adoParam As ADODB.Parameter
Dim rsList As ADODB.Recordset
On Error GoTo ErrHandler:
HourglassMouse
'Work around for Access bug, if there are some rows currently selected, and
'list is requried that has a small number of items, it shows some empty rows
'as selected. Therefore, make sure everything is unselected before
'requerying
SelectAll False
strSearchFor = Trim(Criteria)
If Len(strSearchFor) = 0 Then
strSearchFor = Trim(Nz(txtOrderSearch, ""))
End If
Set adoConn = New ADODB.Connection
adoConn.Open GetSQL2005ConnString
Set adoCmd = New ADODB.Command
adoCmd.ActiveConnection = adoConn
adoCmd.CommandText = "GetInventoryList"
adoCmd.CommandType = adCmdStoredProc
adoCmd.Parameters("@ProductSearch").Value = strSearchFor
adoCmd.Parameters("@SupplierID").Value = Nz(cboOrderSupplier, 0)
adoCmd.Parameters("@ShowBelow").Value = Nz(chkBelow, False)
adoCmd.Parameters("@ShowOpen").Value = Nz(chkOpen, False)
Set rsList = New ADODB.Recordset
rsList.CursorLocation = adUseClient
rsList.Open adoCmd, , , adLockReadOnly
Set Me.lstInvOrder.Recordset = rsList
adoConn.Close
Set adoConn = Nothing
Set adoCmd = Nothing
'Only allow the "Generate All Required Orders" to be clicked if
'a single supplier's orders are being viewed
cmdGenerateAllOrders.Enabled = (Nz(cboOrderSupplier, 0) <> 0)
'Unselect all rows currently selected
SelectAll False
ExitRoutine:
DefaultMouse
Exit Function
ErrHandler:
ReportError Err, Err.Description, "While filtering"
GoTo ExitRoutine
End Function