Re: Search Form, # of Records

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



You are probably right about the nulls.

Typically people put this kind of thing in their query:
Like [Forms].[Form1].[Combo2] & "*"
However, that criterion does NOT return the records where the field is null.

It is possible to write the WHERE clause of the query so the criterion is
True if the combo is null, e.g.:
WHERE (([Forms].[Form1].[Combo2] Is Null)
OR ([MyField] Like [Forms].[Form1].[Combo2] & "*"))
AND ...
You can probably see this gets very convoluted if you have lots of criteria.

A much more efficient solution is to leave the criteria out of the query,
and build the it as a string using only the boxes where the user entered
something. You can then apply it as the WhereCondition for OpenReport, the
Filter of your form, or even as the SQL property of a QueryDef.

For an example, see:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"sunshineleo" <sunshineleo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:6A4FA762-436D-4AA1-B005-3BA18227B1B2@xxxxxxxxxxxxxxxx
I have a search form with combo boxes.... I don't understand why if there
are
700 records, only 620 show up in the query results when nothing is
selected.
I think it may be because some of the fields included in the search have
nothing in the field, or they are Null. How do I overwrite this?
Thanks for the help!


.



Relevant Pages

  • Re: Date format problem?
    ... external source in general date format with full date and time data. ... criteria. ... On my search form, the unbound fields are set to short ... display formats in the query or search form doesn't work, and so far, trying ...
    (microsoft.public.access.queries)
  • RE: Filtering a subform using many combo boxes
    ... SELECT AssignedPriority, AssignedPriorityDetail FROM tblAssignedPriority ... YES for all of the combo boxes.) ... I followed you instructions to the letter and every one of the criteria ... open the query "qryProjects" in design view. ...
    (microsoft.public.access.forms)
  • Re: using a form with combo box to input criteria
    ... Candia Computer Consulting - Candia NH ... When you removed the criteria, ... Then your criteria in the query would be... ... query behind your main report. ...
    (microsoft.public.access.forms)
  • Re: using a form with combo box to input criteria
    ... Candia Computer Consulting - Candia NH ... When you removed the criteria, ... Then your criteria in the query would be... ... query behind your main report. ...
    (microsoft.public.access.forms)
  • RE: Filtering a subform using many combo boxes
    ... I followed you instructions to the letter and every one of the criteria ... I described the typical properties of all my combo boxes in my original ... open the query "qryProjects" in design view. ... I have a main table named tblProjectData that contains all the data for each ...
    (microsoft.public.access.forms)