Passing parameter prompt via code

C

caimito

I have a module for a report that uses DAO to obtain
labels and data fields from the report's underlying query.
My query has a parameter that prompts the user for data.
In order to resolve a "Too few parameters. Expected XX"
error, I found MS Knowledge Base Articles 209203 and
210244. But althouth these articles discuss passing a
prompt as a parameter for a query in code, the example
given does not actually prompt the user. The following
code line is from the article:

kb 209203
qdfSample![Please enter date:] = #8/8/94#

kb 210244
Mydef![Enter a City] = "Seattle"

Both of these lines actually set the value and do not
prompt for the data. I have tried variations of this
using the code below and also an inputbox. The code below
gives an error because the query parameter does not prompt
therby not returning valid fields used in my code:

qdf![Enter the Budget Activity: 54 or 55] = [Enter the
Budget Activity: 54 or 55]

The inputbox caused a prompt to occur twice for the same
parameter data. If the data is not entered exactly the
same the report is erroneous. I know the remainder of my
code works because if I actually put "54" or "55" to the
right of the equal sign the code will use that string for
the parameter and give me the correct report, just like in
the kb articles. The query itself still performs the
separate prompt that appears in its criteria. How do I
get only one prompt that will work in my code and in the
query?
 
K

Ken Snell

What you're seeking to do is not something that I've done, so let me suggest
an approach and let's see if this works for you.

Assuming that the "prompt" parameter is the only parameter in the query, try
this to get the prompt message:
qdf.Parameters(0).Value = [Enter the Budget Activity: 54 or 55]
 
M

Marshall Barton

caimito said:
I have a module for a report that uses DAO to obtain
labels and data fields from the report's underlying query.
My query has a parameter that prompts the user for data.
In order to resolve a "Too few parameters. Expected XX"
error, I found MS Knowledge Base Articles 209203 and
210244. But althouth these articles discuss passing a
prompt as a parameter for a query in code, the example
given does not actually prompt the user. The following
code line is from the article:

kb 209203
qdfSample![Please enter date:] = #8/8/94#

kb 210244
Mydef![Enter a City] = "Seattle"

Both of these lines actually set the value and do not
prompt for the data. I have tried variations of this
using the code below and also an inputbox.

You would need to use your own InputBox.

qdf![Enter the Budget Activity: 54 or 55] = _
InputBox("Enter the Budget Activity: 54 or 55")

How many times the input box appears depends on where you
place the code.
 
G

Guest

Thanks Marsh. As I indicated in my write-up I actually
did try this. But since the query I am running is a saved
query, I got the prompt twice: once from the code and a
second time from the report running the query. The code
gets field information from the query to use as the source
for the report fields. It's a bit messy. But since the
KB article indicates that using prompts as a parameter is
possible I figured there was a correct way to do it.
-----Original Message-----
caimito said:
I have a module for a report that uses DAO to obtain
labels and data fields from the report's underlying query.
My query has a parameter that prompts the user for data.
In order to resolve a "Too few parameters. Expected XX"
error, I found MS Knowledge Base Articles 209203 and
210244. But althouth these articles discuss passing a
prompt as a parameter for a query in code, the example
given does not actually prompt the user. The following
code line is from the article:

kb 209203
qdfSample![Please enter date:] = #8/8/94#

kb 210244
Mydef![Enter a City] = "Seattle"

Both of these lines actually set the value and do not
prompt for the data. I have tried variations of this
using the code below and also an inputbox.

You would need to use your own InputBox.

qdf![Enter the Budget Activity: 54 or 55] = _
InputBox("Enter the Budget Activity: 54 or 55")

How many times the input box appears depends on where you
place the code.
 
G

Guest

Thanbks for your reply Ken. I tried both solutions
proposed and neither worked the way I needed. So I
decided to create another data selection box on a form.
That way, only the query prompts me and I get no errors.
I did it and that solution worked.
-----Original Message-----
What you're seeking to do is not something that I've done, so let me suggest
an approach and let's see if this works for you.

Assuming that the "prompt" parameter is the only parameter in the query, try
this to get the prompt message:
qdf.Parameters(0).Value = [Enter the Budget Activity: 54 or 55]


--
Ken Snell
<MS ACCESS MVP>


I have a module for a report that uses DAO to obtain
labels and data fields from the report's underlying query.
My query has a parameter that prompts the user for data.
In order to resolve a "Too few parameters. Expected XX"
error, I found MS Knowledge Base Articles 209203 and
210244. But althouth these articles discuss passing a
prompt as a parameter for a query in code, the example
given does not actually prompt the user. The following
code line is from the article:

kb 209203
qdfSample![Please enter date:] = #8/8/94#

kb 210244
Mydef![Enter a City] = "Seattle"

Both of these lines actually set the value and do not
prompt for the data. I have tried variations of this
using the code below and also an inputbox. The code below
gives an error because the query parameter does not prompt
therby not returning valid fields used in my code:

qdf![Enter the Budget Activity: 54 or 55] = [Enter the
Budget Activity: 54 or 55]

The inputbox caused a prompt to occur twice for the same
parameter data. If the data is not entered exactly the
same the report is erroneous. I know the remainder of my
code works because if I actually put "54" or "55" to the
right of the equal sign the code will use that string for
the parameter and give me the correct report, just like in
the kb articles. The query itself still performs the
separate prompt that appears in its criteria. How do I
get only one prompt that will work in my code and in the
query?


.
 
M

Marshall Barton

Thanks Marsh. As I indicated in my write-up I actually
did try this. But since the query I am running is a saved
query, I got the prompt twice: once from the code and a
second time from the report running the query. The code
gets field information from the query to use as the source
for the report fields. It's a bit messy. But since the
KB article indicates that using prompts as a parameter is
possible I figured there was a correct way to do it.

Sorry, I'm even more confused now. It's starting to sound
like you're trying to open a recordset on the same query as
the report's record source(??), but you don't want to be
prompted a second time. If so, starting with the report
header's Format event, you can get the value of the
parameter in a text box by using a control source consisting
of the exact parameter name. E.g.

[Enter the Budget Activity: 54 or 55]

In A2K+ you can also use the report's RecordsetClone to
examine the fields in the record source query.
--
Marsh
MVP [MS Access]


-----Original Message-----
caimito said:
I have a module for a report that uses DAO to obtain
labels and data fields from the report's underlying query.
My query has a parameter that prompts the user for data.
In order to resolve a "Too few parameters. Expected XX"
error, I found MS Knowledge Base Articles 209203 and
210244. But althouth these articles discuss passing a
prompt as a parameter for a query in code, the example
given does not actually prompt the user. The following
code line is from the article:

kb 209203
qdfSample![Please enter date:] = #8/8/94#

kb 210244
Mydef![Enter a City] = "Seattle"

Both of these lines actually set the value and do not
prompt for the data. I have tried variations of this
using the code below and also an inputbox.
Marshall said:
You would need to use your own InputBox.

qdf![Enter the Budget Activity: 54 or 55] = _
InputBox("Enter the Budget Activity: 54 or 55")

How many times the input box appears depends on where you
place the code.
 

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