Parameter passed from a form to a query

  • Thread starter Joseph Greenberg
  • Start date
J

Joseph Greenberg

Using Access 2007.

I have a simple form with an opton button array. I want to pass a paramter
based on which option value is selected (there is a default one) - they are
in a frame called fraMemberType. The query currently has a parameter called
[Who]. The possible values that I want to use are "<3", ">2", or ">0" (and
no, thiis isn't the text of the option values). How can I insert one of
these values (without the quotes, of course) into my parameter [Who]?

Thanks.
 
J

Jerry Whittle

Not really. As a parameter Access would see it as ="<3" or =">2" if you
define the parameter as text and probably throw an error if defined as a
number.

You might be able to build an SQL string in a module that could use the form
field.
 
M

MGFoster

Joseph said:
Using Access 2007.

I have a simple form with an opton button array. I want to pass a paramter
based on which option value is selected (there is a default one) - they are
in a frame called fraMemberType. The query currently has a parameter called
[Who]. The possible values that I want to use are "<3", ">2", or ">0" (and
no, thiis isn't the text of the option values). How can I insert one of
these values (without the quotes, of course) into my parameter [Who]?


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

If the Frame returns 1, 2, or 3 you can use the Choose() function:

PARAMETERS Forms!FormName!fraMemberType Byte;
SELECT....
FROM....
WHERE Choose(Forms!FormName!fraMemberType,
column_name<3,
column_name>2,
column_name>0)

Choose is usually all on one line, I just broke it out for clarity.

HTH,
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

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

iQA/AwUBSp8cTYechKqOuFEgEQLoXACfUg8ik7EUIJwgR7I1njT540N9rKwAn0P4
u7I2opAH/lZAKigcVgqBGqz1
=nqXd
-----END PGP SIGNATURE-----
 
J

Joseph Greenberg

The only other way I can think to do this is to define a global variable,
reinitialize it to blank at the end of the proc that calls the query, and
set the global variable in the click event of the option buttons. this seems
wasteful, but it should work, right?

Jerry Whittle said:
Not really. As a parameter Access would see it as ="<3" or =">2" if you
define the parameter as text and probably throw an error if defined as a
number.

You might be able to build an SQL string in a module that could use the
form
field.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Joseph Greenberg said:
Using Access 2007.

I have a simple form with an opton button array. I want to pass a
paramter
based on which option value is selected (there is a default one) - they
are
in a frame called fraMemberType. The query currently has a parameter
called
[Who]. The possible values that I want to use are "<3", ">2", or ">0"
(and
no, thiis isn't the text of the option values). How can I insert one of
these values (without the quotes, of course) into my parameter [Who]?

Thanks.
 
J

Joseph Greenberg

and one other follow-up question - would it be possible to pass the index
value to the query (like if I didn't need the greater than or less than
signs)?

Jerry Whittle said:
Not really. As a parameter Access would see it as ="<3" or =">2" if you
define the parameter as text and probably throw an error if defined as a
number.

You might be able to build an SQL string in a module that could use the
form
field.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Joseph Greenberg said:
Using Access 2007.

I have a simple form with an opton button array. I want to pass a
paramter
based on which option value is selected (there is a default one) - they
are
in a frame called fraMemberType. The query currently has a parameter
called
[Who]. The possible values that I want to use are "<3", ">2", or ">0"
(and
no, thiis isn't the text of the option values). How can I insert one of
these values (without the quotes, of course) into my parameter [Who]?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top