Reference a parameter

  • Thread starter Thread starter mc77
  • Start date Start date
M

mc77

I know how to reference a parameter value on a report, but is it possible to
do it on a form? I have tried setting it up the same way as for a report,
but it does not work.
 
Should be similar. Show us what you've tried on a form, and what is working
on a report.
 
On the report I created a text box with the following in the control source:

="You searched for:" & " " & [Enter Patient Name and *]

I tried the same for the form, but it just gives me:

#NAME?
 
On the report I created a text box with the following in the control source:

="You searched for:" & " " & [Enter Patient Name and *]

I tried the same for the form, but it just gives me:

#NAME?

Ken Snell said:
Should be similar. Show us what you've tried on a form, and what is working
on a report.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/

Forms work differently than reports in this regards.

Add a new column to the query.
MyParam:[Enter Patient Name and *]

Make sure the above bracketed text is exactly the same as the query
parameter prompt

Then in the form add an unbound text control:
= "You searched for: " & [MyParam]

Make sure this new field is included in the form's recordsource.
 
Thank you! That worked beautifully.

fredg said:
On the report I created a text box with the following in the control source:

="You searched for:" & " " & [Enter Patient Name and *]

I tried the same for the form, but it just gives me:

#NAME?

Ken Snell said:
Should be similar. Show us what you've tried on a form, and what is working
on a report.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/

I know how to reference a parameter value on a report, but is it possible
to
do it on a form? I have tried setting it up the same way as for a report,
but it does not work.

Forms work differently than reports in this regards.

Add a new column to the query.
MyParam:[Enter Patient Name and *]

Make sure the above bracketed text is exactly the same as the query
parameter prompt

Then in the form add an unbound text control:
= "You searched for: " & [MyParam]

Make sure this new field is included in the form's recordsource.
 
So I have another problem related to this. The whole point is that the users
wanted to be able to see if they typed the parameter incorrectly or if the
record is truly not in the database. Yet, when they type a name that isn't
in the databse the text box for the parameter reference comes up blank. Any
suggestions?

mc77 said:
Thank you! That worked beautifully.

fredg said:
On the report I created a text box with the following in the control source:

="You searched for:" & " " & [Enter Patient Name and *]

I tried the same for the form, but it just gives me:

#NAME?

:

Should be similar. Show us what you've tried on a form, and what is working
on a report.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/

I know how to reference a parameter value on a report, but is it possible
to
do it on a form? I have tried setting it up the same way as for a report,
but it does not work.

Forms work differently than reports in this regards.

Add a new column to the query.
MyParam:[Enter Patient Name and *]

Make sure the above bracketed text is exactly the same as the query
parameter prompt

Then in the form add an unbound text control:
= "You searched for: " & [MyParam]

Make sure this new field is included in the form's recordsource.
 
If the query does not return any records, then there will be no record that
the form can read to show you the parameter. You need to put a textbox on a
"search form" that lets the user type in the parameter, then run a query
that reads the textbox as the parameter. That way, the parameter is showing
on the form, regardless of whether there were records returned or not.

See this article for examples of how different controls can be used:
Using Controls to filter a form's data
http://www.accessmvp.com/KDSnell/SampleDBs.htm#FilterForm


If the above setup is more complicated than you desire, you can put a
textbox on a form and use it as a parameter in a query:

SELECT *
FROM TableName
WHERE FieldName Like Forms!NameOfForm!NameOfTextbox & "*";

The form must be open when the query is run. You also can use a query like
this as the form's RecordSource and not need to save a separate query:

SELECT *
FROM TableName
WHERE FieldName Like [NameOfTextbox] & "*";

To use the above setup, you'll need to requery the form in the textbox's
AfterUpdate event.
--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



mc77 said:
So I have another problem related to this. The whole point is that the
users
wanted to be able to see if they typed the parameter incorrectly or if the
record is truly not in the database. Yet, when they type a name that
isn't
in the databse the text box for the parameter reference comes up blank.
Any
suggestions?

mc77 said:
Thank you! That worked beautifully.

fredg said:
On Wed, 3 Jun 2009 09:06:03 -0700, mc77 wrote:

On the report I created a text box with the following in the control
source:

="You searched for:" & " " & [Enter Patient Name and *]

I tried the same for the form, but it just gives me:

#NAME?

:

Should be similar. Show us what you've tried on a form, and what is
working
on a report.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/

I know how to reference a parameter value on a report, but is it
possible
to
do it on a form? I have tried setting it up the same way as for a
report,
but it does not work.



Forms work differently than reports in this regards.

Add a new column to the query.
MyParam:[Enter Patient Name and *]

Make sure the above bracketed text is exactly the same as the query
parameter prompt

Then in the form add an unbound text control:
= "You searched for: " & [MyParam]

Make sure this new field is included in the form's recordsource.
 
Back
Top