Re: Help creating a query



I find it much more straighforward to create a "base query" without any
criteria, and then enhance its SQL in VBA code with criteria that I obtain
from the selection Form, using the enhanced SQL in the RecordSource of the
pertinent Form or Report, or in the WhereCondition of a DoCmd.OpenForm or
DoCmd.OpenReport.

An advantage of this approach is that you need do nothing to accomodate
returning all values, for selection criteria not entered on the Form -- you
just do not create selection criteria in the WHERE clause you are building.

Larry Linson
Microsoft Access MVP

"DeanL" <deanpmlonghurst@xxxxxxxxx> wrote in message
news:1152309197.456891.259660@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi Guys,

I need some help creating a query that is going to take between 1 and
10 parameters. The parameters are entered on a form into text boxes
that may have data or be empty. Is there a way to create a single
query that will take parameters if they are present in the text boxes
and not take parameters if the text box is empty?

The ten fields will need to be searched using "Like" so that the user
can search on part of a text string (all the fields are text).

With my limited knowledge of Access it seems that the only way I can
currently see is to create a single query for EACH version of
selections which would amout to about a 1000 queries (as I said, my
knowledge is somewhat limited in this area.).

Many thanks for any help, Dean...



.



Relevant Pages

  • Re: SQL Syntax Error
    ... match all the criteria you input. ... SQL view and never open it in the query grid view. ... The syntax for the "where" statement is incorrect becuase of this. ...
    (microsoft.public.access.queries)
  • Re: Using combo box to search form
    ... "Jeff Boyce" wrote: ... Since you "started adding" additional criteria, ... about SQL syntax to know how to form a grammatically-correct SQL statement. ... One way to do that is to see what Access generates when you build a query. ...
    (microsoft.public.access.formscoding)
  • Re: Adjusting SQL in Query
    ... from the RESPEL table which satisfy the criteria in the PRICELIST Table. ... RESPEL INNER JOIN PRICELIST ON RESPEL.PRICELIST = ... Subject: Adjusting SQL in Query ...
    (microsoft.public.access.queries)
  • Re: Criteria linked to form combo Yes/No or All expression help
    ... The way I'd debug it would be to start w/ one OR clause in the criteria. ... Run the query & see if it works for that criteria. ... I followed your suggestion of pasting the sql, ...
    (microsoft.public.access.queries)
  • Re: Using combo box to search form
    ... Since you "started adding" additional criteria, ... about SQL syntax to know how to form a grammatically-correct SQL statement. ... One way to do that is to see what Access generates when you build a query. ... Dim strWhere As String ...
    (microsoft.public.access.formscoding)