1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Access 2007 search code

Discussion in 'Business Applications' started by ElectricianGuy, Oct 30, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. ElectricianGuy

    ElectricianGuy Thread Starter

    Joined:
    Oct 30, 2007
    Messages:
    3
    Does anyone know any good code that I can put in a form in my 2007 Access Database that will allow the user to perform a search for a specific record across all fields in one of my tables?

    Specifically, I would like to put code behind the code builder that would ask the user what they are searching for in the form, and would then allow them to keep searching for the next found record.

    Any code help would be great!
     
  2. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    You could do it using VBA code but there would have to be quite a bit of Code to cover all fields in the table.
    Why not just use a search Query to find all the records, it can be made more flexible as you can do pattern matching and find "more than one field" at a time, i.e. a date and a name, for instance
     
  3. ElectricianGuy

    ElectricianGuy Thread Starter

    Joined:
    Oct 30, 2007
    Messages:
    3
    I am working in a form created from a querry (I don't want users to be able to see any of my actual querry forms or actual tables). Is there a way to create a new button on the existing form that would allow the user to define an additional filter or querry through a dialog box or something? Specifically, if the current form displays 35 records from a table of 700, and the user wants to search the form of 35 records for any of the 35 records that has the text "billboard" in it, can it be done? Let's say of the 35, 3 records has the text billboard in a field called "Task". The assumption would be that the new filter would be temporary--when they type the search criteria of "billboard", only 3 of the 35 records would be visible, but the next time they accessed the form it would show the original 35 records again.

    It seems to me the only way to do that would be through code, but I can't make it happen. If it can be done through an additional querry (without having to create a new form for the new querry), that would be great.
     
  4. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    It could be done with a Query and some simple VBA.
    Or the second search Filter could be added to the original Search that set the first filter.
    I have posted a few "Search Forms" databases on here in the past.
     
  5. slurpee55

    slurpee55

    Joined:
    Oct 20, 2004
    Messages:
    7,837
    Electricianguy, if you could post your database (zip it first), you will probably get at least one quick fix to what you are wanting.
     
  6. ElectricianGuy

    ElectricianGuy Thread Starter

    Joined:
    Oct 30, 2007
    Messages:
    3
    Thanks for the thoughts and comments! I did figure out a simple work-around by holding the search text, closing the form, and re-opening the form set to the search text (by macros). Although the open/close thing is annoying, it works. However, if anyone knows where I could go to view some VBA search code examples, I'd be appreciative.

    As far as posting the database--I have about 80 different forms on it and probably twice that many reports and filters--and would probably make everyone laugh if they saw how many work-arounds I have programmed into it (in otherwords, I hate to advertise my ignorance by posting it). One of these days I'll actually get good at this?!!??!
     
  7. slurpee55

    slurpee55

    Joined:
    Oct 20, 2004
    Messages:
    7,837
    LOL - I can at least agree with you on the "ignorance" part - I know zero code and find all sorts of messy ways to deal with stuff! But the people on here are absolutely marvelous - don't be ashamed, just ask and learn!
    If it is the one form, etc. that is bugging you, copy your database and strip out everything that is not needed (or make a blank and import the few items you need - might be less work) - it sounds like you would just need a few tables and a form.
     
  8. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/645659

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice