Creating a Search Form in Access 2003

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NLR2008
    New Member
    • Dec 2008
    • 2

    Creating a Search Form in Access 2003

    Hi there,

    Can anybody help me and provide me with a SIMPLE solution to create a search form in Access 2003.

    I have created a database for Finance Payments and want to enable the user to search on a number of different fields and to return records that meet the criteria in a subform below.

    I'm testing this at the moment. So far i have:

    3 unbound text boxes (to input the search parameters)

    * TxtName (Name of Payee)
    * TxtDate2 (Date)
    * TxtInvoice (Invoice Number)

    A sub form (frm_subformsea rch) based on a query (qry_searchform ) which gives me a list of all the records.

    I'm basically stuck on the coding for selecting where the text boxes meet the criteria and returning these in the sub form.

    I have downloaded a code from a website but it's not working - Can you tell me where i'm going wrong. Please note the code below is as was downloaded - i've not posted what i tried to do to tailor it to my database

    Private Function BuildFilter() As Variant
    Dim varWhere As Variant
    Dim varColor As Variant
    Dim varItem As Variant
    Dim intIndex As Integer

    varWhere = Null ' Main filter
    varColor = Null ' Subfilter used for colors

    ' Check for LIKE First Name
    If Me.txtFirstName > "" Then
    varWhere = varWhere & "[FirstName] LIKE """ & Me.txtFirstName & "*"" AND "
    End If

    ' Check for LIKE Last Name
    If Me.txtLastName > "" Then
    varWhere = varWhere & "[LastName] LIKE """ & Me.txtLastName & "*"" AND "
    End If

    Please help!

    Thank you,

    Nia x
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Why are you using > to compare string.
    Need to use Length function instead.

    Comment

    Working...