How do I prompt query for several parameters?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want data to appear for certain water well IDs. Prompt is "Which wells?"
How do I set it up so that I can type in several well IDs? I can only do one
well at a time right now.
How about a drop down menu for the prompt? Is that possible?
How about a drop down menu that allows me to select several parameters (Well
IDs)?
 
Mary Jean,
It depends on whether or not you are wanting to query IDs that are
sequential or non-sequential. If they are sequential you can use a Between
clause in your criteria:

Between [First ID] AND [Last ID]

If they are non sequential, things get much harder and you would probably
need to create a form with several unbound text boxes on it. Obviously, you
would need to know how many choices your users might need. The where clause
of your query would then become something like:

WHERE WellID = Forms!YourFormName!YourComboBox1 OR WellID =
Forms!YourFormName!YourComboBox2 OR WellID =
Forms!YourFormName!YourComboBox3 WellID = Forms!YourFormName!YourComboBox4

If you don't know how many choices they might want to query on, then you
could add a text box that allowed them to enter the number of WellIDs they
wanted to query and then, in code, add enough comboboxes to the form for the
query.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html
 
MaryJean said:
I want data to appear for certain water well IDs. Prompt is "Which wells?"
How do I set it up so that I can type in several well IDs? I can only do one
well at a time right now.
How about a drop down menu for the prompt? Is that possible?
How about a drop down menu that allows me to select several parameters (Well
IDs)?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You can set up the WHERE clause of the query to use the InStr() trick.
E.g.:

PARAMETERS [Enter a comma-delimited list of well IDs] TEXT(255);
SELECT ...
FROM ...
WHERE InStr(',' & [Enter a comma-delimited list of well IDs] & ',' , ','
& WellID & ',')>0

The InStr() trick scans the WellID column for any well ID that was
passed in the [Enter a comma-delimited list of well IDs] parameter. Any
record that has one of the parameter IDs will be selected. There
shouldn't be any spaces in the parameter string. IOW, this:

1,25,33,44,66

instead of this:

1, 25, 33, 44, 66
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBREfbDYechKqOuFEgEQIOiACg7crII6wtI8MJICe6kMn6PtXJd18An2Kj
SGiW2DYXU3U8fW0o5ZOilzY2
=NJ8b
-----END PGP SIGNATURE-----
 
Back
Top