Creating Search Form

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

I have a Table with 5 Fields. Name, City, State, Zip, Registration
Date.

I trying to design a form where I can search a date range within the
Registration Date field and search the remaining fields at the same
time. Plus I need results even is there is not a value in a paticular
field. For example, I'll do a search for State and a date range and
leave the other fields blank.

I have the form created and can search only one field at a time. I'm
sure my query criteria is way off. Any help greatly appreciated.

Jason.
 
Jason,
Unless you're a pretty good Access programmer, building a search form
with so many variables can be a daunting task.
Have you checked out the built-in FilterByForm function? It allows you
to set up multiple criteria within form fields, just as you want. I would
suggest using this method, rather than reinventing the wheel.


Basically though, a multi-field search criteria form requires examining
each of the five fields, and "building" a "Where" statement for the Find
function.
City = "Boston" could be called Arg1 (argument)
State = "MA" could be called Arg2

Then... FindRecord................ Where Arg1 and Arg2... etc...
If [Name] was left blank on the search form, just don't include that
argument in the Where... and all names within criteria will be returned.

This is just the concept. You'll have to work out the specific code for
your own situation.

Again... I recommend the FilterByForm, that's what it's there for. And
with a little practice, it should do just what you want.

hth
Al Camp
 
Well I developed a form just like what you are requesting with some
variances. I used a program from this site and just changed it to what I
need.

http://www.datastrat.com/Download2.html

I did however, like AlCamp stated had to do a lot of VB code to get it the
way I like. I used 2 text boxes and 2 combo boxes to populate a list box
depending on which control(s) had any text in them. Then from my selection on
the listbox populated another form.
 
Back
Top