scottsanpedro
asked on
BuildCriteria
I'm running a popup box that allows the user to enter some criteria to filter out a form...The problem is with strInput1 and strInput2. If the user doesn't input anything in this field then I want the BuildCriteria to run the command with the following
Like "*" or is null
I've left the latest concatenation in for example purposes..
Dim frm As Form
Dim strInput As String, strFilter As String, strInput2 As String, strinput3 As String
Dim rs As Recordset
Set frm = Forms!frmBasePlanMain
If IsNull(Forms!frmBasePlanMa inSearch!T xtSiteName ) Then
MsgBox "You Must Enter a Site Name"
Exit Sub
Else
strInput = Forms!frmBasePlanMainSearc h!TxtSiteN ame
End If
If IsNull(Forms!frmBasePlanMa inSearch!t xtExchUnit ) Then
strInput2 = "*" & "' or is null '"
Else
strInput2 = Forms!frmBasePlanMainSearc h!txtExchU nit
End If
If IsNull(Forms!frmBasePlanMa inSearch!t xtExchExt) Then
strinput3 = "*" & "' or is null '"
Else
strinput3 = Forms!frmBasePlanMainSearc h!txtExchE xt
End If
strFilter = BuildCriteria("exchname", dbText, strInput)
strFilter = strFilter & " AND " & BuildCriteria("ExchUnit", dbText, strInput2)
strFilter = strFilter & " AND " & BuildCriteria("ExchExt", dbText, strinput3)
Set rs = CurrentDb.OpenRecordset("S ELECT * FROM BasePlan WHERE " & strFilter, dbOpenSnapshot)
If Not rs.EOF Then
frm.Filter = strFilter
frm.FilterOn = True
frm.OrderBy = "apack DESC"
frm.OrderByOn = True
rs.Close
Else
MsgBox "No Records Returned"
rs.Close
End If
Any help??
Scottsanoedro
Like "*" or is null
I've left the latest concatenation in for example purposes..
Dim frm As Form
Dim strInput As String, strFilter As String, strInput2 As String, strinput3 As String
Dim rs As Recordset
Set frm = Forms!frmBasePlanMain
If IsNull(Forms!frmBasePlanMa
MsgBox "You Must Enter a Site Name"
Exit Sub
Else
strInput = Forms!frmBasePlanMainSearc
End If
If IsNull(Forms!frmBasePlanMa
strInput2 = "*" & "' or is null '"
Else
strInput2 = Forms!frmBasePlanMainSearc
End If
If IsNull(Forms!frmBasePlanMa
strinput3 = "*" & "' or is null '"
Else
strinput3 = Forms!frmBasePlanMainSearc
End If
strFilter = BuildCriteria("exchname", dbText, strInput)
strFilter = strFilter & " AND " & BuildCriteria("ExchUnit", dbText, strInput2)
strFilter = strFilter & " AND " & BuildCriteria("ExchExt", dbText, strinput3)
Set rs = CurrentDb.OpenRecordset("S
If Not rs.EOF Then
frm.Filter = strFilter
frm.FilterOn = True
frm.OrderBy = "apack DESC"
frm.OrderByOn = True
rs.Close
Else
MsgBox "No Records Returned"
rs.Close
End If
Any help??
Scottsanoedro
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers
Scott
Scott
ASKER
Thanks very much
How it should be..Nice and quick
Cheers
Scott