Solved

BuildCriteria

Posted on 2000-02-18
3
432 Views
Last Modified: 2008-03-03
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
0
Comment
Question by:scottsanpedro
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
paasky earned 50 total points
ID: 2535096
Hello scottsanpedro,

Try this:

....
    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
           
            strFilter = BuildCriteria("exchname", dbText, strInput)
             
            If Not IsNull(Forms!frmBasePlanMainSearch!txtExchUnit) Then
                strFilter = strFilter & " AND " & BuildCriteria("ExchUnit", dbText, strInput2)
            End If
             
            If Not IsNull(Forms!frmBasePlanMainSearch!txtExchExt) Then
                strFilter = strFilter & " AND " & BuildCriteria("ExchExt", dbText, strinput3)
            End If
       
    Set rs = CurrentDb.OpenRecordset("SELECT * FROM BasePlan WHERE " & strFilter, dbOpenSnapshot)
....
....
     
Regards,
Paasky
0
 
LVL 1

Author Comment

by:scottsanpedro
ID: 2535124
Of course...

Thanks very much

How it should be..Nice and quick

Cheers

Scott
0
 
LVL 1

Author Comment

by:scottsanpedro
ID: 2535128
Cheers

Scott
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now