SQL to allow a "no preference (all) choice

Ask a Question related to ASP Database, Design and Development.

  1. #21

    Default Re: SQL to allow a "no preference (all) choice

    One last question:

    Since I would like to populate both MeetingLocation and GroupMix dropdowns
    in the form from the data, how can I add the selection option of "Any" to
    the list when the list is being created by a query?

    Thanks (again)
    RP

    "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:%23s6fWI5YEHA.3420@TK2MSFTNGP12.phx.gbl...
    > Rich Palarea wrote:
    > > The SQL out of Access looks like this:
    > >
    > > SELECT Smallgroups.OrgID, Smallgroups.Name, Smallgroups.MeetingDay,
    > > Smallgroups.MeetingLocation, Smallgroups.GroupMix,
    > > Smallgroups.MeetingTime, Smallgroups.ChildrenAllowed,
    > > Smallgroups.Status, Smallgroups.ContactIndLabel,
    > > Smallgroups.ContactHomePhone, Smallgroups.ContactIndvEmail
    > > FROM Smallgroups
    > > WHERE (((Smallgroups.MeetingDay)=[Meeting Day:]) AND
    > > ((Smallgroups.MeetingLocation)=[Meeting Location:]) AND
    > > ((Smallgroups.GroupMix)=[Group Mix:]) AND
    > > ((Smallgroups.Status)="open"));
    > >
    >
    > My first suggestion is to get rid of the spaces and colons from the
    > parameter names. It's just my personal preference, but I like to avoid
    > non-alpha characters in my object names. It makes them easier to use in
    > code, and if you prefix them with "p", you'll never have any doubt you are
    > looking at a parameter.
    >
    > My next suggestion is to use table aliases so you don't have to keep
    typing
    > and reading the names of the tables in your sql statement. Actually, since
    > there is a single table in your FROM clause, there is no need to clutter
    up
    > your query with aliases either.
    >
    > So, after implementing the above suggestions, and eliinating the
    unnecessary
    > parentheses from your WHERE clause, the query looks like this:
    >
    > SELECT OrgID, Name, MeetingDay,
    > MeetingLocation, GroupMix, MeetingTime,
    > ChildrenAllowed, Status,
    > ContactIndLabel, ContactHomePhone,
    > ContactIndvEmail
    > FROM Smallgroups
    > WHERE MeetingDay=[pMeetingDay] AND
    > MeetingLocation=[pMeetingLocation] AND
    > GroupMix=[pGroupMix]
    > AND Status="open"
    >
    >
    > > Because of the limited number of records currently in the database,
    > > we'd like to allow users to open the filters up a bit by selecting
    > > "Any" for MeetingDay, MeetingLocation and GroupMix.
    > >
    > > MeetingDay are all of the days of the week (Sun-Sat), MeetingLocation
    > > are cities that are read out of the database and populate a drop down
    > > menu in the .asp page (using DISTINCT). GroupMix is a drop down
    > > populated the same way as MeetingLocation.
    > >
    > > Did I provide you with the correct info?
    >
    > Yes. Here is how to implement the "Any" filter:
    >
    > WHERE
    > (MeetingDay= [pMeetingDay] OR [pMeetingDay] = "Any")
    > AND
    > (MeetingLocation= [pMeetingLocation] OR [pMeetingLocation] = "Any")
    > AND
    > (GroupMix= [pGroupMix] OR [pGroupMix] = "Any")
    > AND Status="open"
    >
    >
    > Make this change to your query and test it in Access, supplying the word
    > "Any" to one or more of the parameter prompts to verify that it works as
    > intended. In ASP, pass the word "Any" to the query for those parameters
    for
    > which the user chose "Any".
    >
    > HTH,
    > Bob Barrows
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >

    Rich Palarea Guest

  2. Similar Questions and Discussions

    1. Any know how to avoid "Do you also want to uninstall Contribute Preference and configuration files for other users on this computer?"
      Hi, When uninstalling Contribute 3.01 or installing 3.11, which removes previous versions, there is a prompt asking 'Do you also want to...
    2. Preference files
      I have the Classroom in a book for IDCS. It advises that I must reset the preference files for each lesson. To do this I am to delete the preference...
    3. Help with preference file
      Running Illustrator 10.0.3 and having trouble with swatches, styles etc. not being saved. A posted solution says to upgrade to v 10.0.3 but I am...
    4. Preference file
      Anyone know a website where someone might swap "Prefence files" with other Photoshop users?
    5. Where are preference files?
      I think I have a corrupted Internet preference file: in the preference pane, I have Safari selected as my default browser, but other applications...
  3. #22

    Default Re: SQL to allow a "no preference (all) choice

    If you don't want to use code to add the "Any" option (which is not that
    hard to do), you can use a UNION query. If you show me one of the queries
    and let me know where in the list you want the "Any" option to occur, I'll
    provide an example ... unless someone else beats me to it. :-)

    Bob Barrows

    Rich Palarea wrote:
    > One last question:
    >
    > Since I would like to populate both MeetingLocation and GroupMix
    > dropdowns in the form from the data, how can I add the selection
    > option of "Any" to the list when the list is being created by a query?
    >
    > Thanks (again)
    > RP

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139