Form Search Engine - Please help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dbar10
    New Member
    • Nov 2008
    • 17

    Form Search Engine - Please help

    I am working on a form in my application for a Worker Profile evrything is working fine except the Search Box. I have to be able to search on two criteria. One is the WorkStatus i.e. Active, Inactive,etc. and 1 of three other choices. First Name, Last Name or SSN. I have pIaced 4 unbound text boxes on my form tied to the select query that pulls all the records called Work Add/Edit Query. I can run with the status and it works fine but how do I include one of my other criteria with that? As soon as I add another criteria to my query it doesn't work. I am stumped. Doug
    Last edited by Dbar10; Nov 23 '08, 11:54 PM. Reason: Needed to add a better description
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by Dbar10
    I am working on a form in my application for a Worker Profile evrything is working fine except the Search Box. I have to be able to search on two criteria. One is the WorkStatus i.e. Active, Inactive,etc. and 1 of three other choices. First Name, Last Name or SSN. I have pIaced 4 unbound text boxes on my form tied to the select query that pulls all the records called Work Add/Edit Query. I can run with the status and it works fine but how do I include one of my other criteria with that? As soon as I add another criteria to my query it doesn't work. I am stumped. Doug
    You might find it more helpful doing every thing query based in Access, and keep very little coding in your VB app...

    See if this can help guide you:

    [CODE=VB]

    Set my_database = OpenDatabase("C :\DataGram\Data _Central.mdb")

    'this function will open your database in access (provided that it is closed access)

    Set my_record = my_database.Ope nRecordset("SEL ECT * FROM LIBRARY WHERE Your_Price LIKE '" & Text1(0).Text & "' OR Name LIKE'" & Text1(1).Text & "'")

    ' above is used to search by price and/ or name, only if data already exist
    'you can also add AND there to fit your needs...

    Do While Not my_record.EOF 'this function will keep searching for fields matching each textbox
    Text1(0).Text = my_record.field s("Your_Price ")
    Text1(1).Text = my_record.field s("Name")
    Text1(2).Text = my_record.field s("Type")
    Text1(3).Text = my_record.field s("Crime_Rate_1 ")
    Text1(4).Text = my_record.field s("Crime_Rate_2 ")

    [/CODE]

    Post your code if this isn't it, but above runs here looking for price for appartments and name depending on similarity.

    Hope this helps!
    Last edited by Dököll; Nov 24 '08, 12:27 AM. Reason: CODE brackets, plus comment...

    Comment

    • Dbar10
      New Member
      • Nov 2008
      • 17

      #3
      Thank you. I only have this in a query in Access. I don't know where to put this code. Is it in each of the unbound boxes? Sorry, I am not well versed in VB. I can do simple things, but can this be done in a select query?

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        why not filter the data based on criteria in the SQL query itself using LIKE .

        Comment

        • Dbar10
          New Member
          • Nov 2008
          • 17

          #5
          Awesome

          What was I thinking? Thank you. That worked great.

          Comment

          Working...