Link to home
Start Free TrialLog in
Avatar of scottsanpedro
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!frmBasePlanMainSearch!TxtSiteName) Then
                MsgBox "You Must Enter a Site Name"
                Exit Sub
            Else
            strInput = Forms!frmBasePlanMainSearch!TxtSiteName
            End If
           
            If IsNull(Forms!frmBasePlanMainSearch!txtExchUnit) Then
                strInput2 = "*" & "' or is null '"
            Else
            strInput2 = Forms!frmBasePlanMainSearch!txtExchUnit
            End If
           
            If IsNull(Forms!frmBasePlanMainSearch!txtExchExt) Then
                strinput3 = "*" & "' or is null '"
            Else
            strinput3 = Forms!frmBasePlanMainSearch!txtExchExt
            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("SELECT * 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
ASKER CERTIFIED SOLUTION
Avatar of paasky
paasky
Flag of Finland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of scottsanpedro
scottsanpedro

ASKER

Of course...

Thanks very much

How it should be..Nice and quick

Cheers

Scott
Cheers

Scott