By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,600 Members | 1,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,600 IT Pros & Developers. It's quick & easy.

Passing Values to Parameter Query

P: n/a
MX1
I'm ready to pull the hair out of my head. I have a query with a couple of
parameters that I want to get from combo boxes on a form. One parameter is
a date with a dynamically calculated year and the other is criteria for a
Yes or No field. I'll focus on the Yes/No field for simplicity.

If I run the query with the criteria hard coded as either "YES" or "NO", it
works.
In the values of the combo box in my form, I have it set as follows:

"Check Only";No;"DAF Only";Yes;"Both";Yes Or No

No matter what I select and the run the query,it does not like the value
passed to it. I've checked the values in memory via a msgbox for
troubleshooting and they are indeed yes, no, or yes or no. Does anyone know
how I have to pass values from a combo box on a form into a parameter query
so that it recognizes it? PLEASE HELP.
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
MX1
Update - I've managed to make the Yes and No value work by being passed from
the combo box of the form by changing the query's parameter section. I tell
it that this variable getting picked up from the form's combo box is of type
value. Again, works for Yes and No values. However, it doesn't like the
'YES Or NO' entry. It chokes on that. I can't believe how complicated this
simple little task has become. The battle rages on...

"MX1" <mx*@mx1.abc> wrote in message
news:5JLEb.155142$_M.728466@attbi_s54...
I'm ready to pull the hair out of my head. I have a query with a couple of parameters that I want to get from combo boxes on a form. One parameter is a date with a dynamically calculated year and the other is criteria for a
Yes or No field. I'll focus on the Yes/No field for simplicity.

If I run the query with the criteria hard coded as either "YES" or "NO", it works.
In the values of the combo box in my form, I have it set as follows:

"Check Only";No;"DAF Only";Yes;"Both";Yes Or No

No matter what I select and the run the query,it does not like the value
passed to it. I've checked the values in memory via a msgbox for
troubleshooting and they are indeed yes, no, or yes or no. Does anyone know how I have to pass values from a combo box on a form into a parameter query so that it recognizes it? PLEASE HELP.

Nov 12 '05 #2

P: n/a
Hi,

On Fri, 19 Dec 2003 23:20:33 GMT, MX1 wrote:
I'm ready to pull the hair out of my head. I have a query with a couple of
parameters that I want to get from combo boxes on a form. One parameter is
a date with a dynamically calculated year and the other is criteria for a
Yes or No field. I'll focus on the Yes/No field for simplicity.

If I run the query with the criteria hard coded as either "YES" or "NO", it
works.
In the values of the combo box in my form, I have it set as follows:

"Check Only";No;"DAF Only";Yes;"Both";Yes Or No


check out the EVAL-function. I.E. from within your query:

SELECT Eval("forms!YourFormName!cboYourComboName.column(1 )") AS Result_Col1

Using it like that you won't need a "real" parameter-query.

But if you prefer using code with a query like ...
PARAMETERS whatever Integer;
SELECT Something FROM Somewhere
WHERE SomeField = whatever
.... then you'd use it from code like this:
dim db as dao.database
dim qdf as dao.querydef
dim rs as dao.recordset
set db=currentdb
set qdf=db.querydefs("NameOfQuery")
qdf.parameters("whatever")=0
set rs=qdf.openrecordset(dbopensnapshot)
with rs
...

Cheers,
Olaf [MVP]
--
My .02: www.Resources.IntuiDev.com
Nov 12 '05 #3

P: n/a
rkc

"MX1" <mx*@mx1.abc> wrote in message
news:WTLEb.433568$275.1300044@attbi_s53...
Update - I've managed to make the Yes and No value work by being passed from the combo box of the form by changing the query's parameter section. I tell it that this variable getting picked up from the form's combo box is of type value. Again, works for Yes and No values. However, it doesn't like the
'YES Or NO' entry. It chokes on that. I can't believe how complicated this simple little task has become. The battle rages on...


If you create a query with a Yes/No parameter using the menu choice
Query - Parameters the data type is set as Bit. If you do that then for
some
reason Access accepts YES/NO, TRUE/FALSE, ON/OFF or the number
0 (zero) as False and any other number as True.

That will work when either Yes or No is returned by your combo box.
'Yes or No' will never work as a Yes/No (Bit) parameter because it is not
an acceptable value.

You'll probably have to build in logic to run a different query when you
don't
care if the value is Yes or No.

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.