Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Show query parameter on form

Posted on 2013-12-11
5
Medium Priority
?
791 Views
Last Modified: 2013-12-12
I tought this should be easy, but don't understand why it does not work. I have a form with a query as the controlsource. In the query I have a parameter like this: [What is the credit limit:] Workes fine in query, but how can I display this value on my form. I tought I could use an unbound textbox with controlsource like this =[What is the credit limit:], but the result is #Name?. What is wrong. Appreciate any tips or hint. And what if I want a title in the form that user should give when form is open?
0
Comment
Question by:hallpett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 53

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 300 total points
ID: 39713391
Hi,

pls refer to

http://office.microsoft.com/en-us/access-help/using-parameters-with-queries-and-reports-HA001117077.aspx

look for
Creating a form to supply parameters to a query


Regards
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 600 total points
ID: 39713709
That link doesn't look like it is quite on target.

If you have a textbox on a form that you are trying to use to filter the data on the same form, do this.  I'm assuming the field you are trying to filter is called "CreditLimit", and the textbox you are entering the criteria in is called txtCreditLimit.  Change the code accordingly if you are using different names:

1.  Leave the textbox unbound, and make its controlsource property blank so that the user can enter text in it.

2.  Add a command button to the form

3.  Place the following VBA in the click event of the command button:

Me.Filter = "[CreditLimit] = " & Me,txtCreditLimit
Me.FilterOn = true

Open in new window

0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 39713827
So, my understanding is that you have a query that looks like:

SELECT *
FROM yourTable
WHERE [CreditLimit] = [What is the credit limit:]

You could change this to:

SELECT *, [What is the credit limit:] as Limit
FROM yourTable
WHERE [CreditLimit] = [What is the credit limit:]

but this would accomplish nothing since you already have the [CreditLimit] field in the query, and since you are using an equality in your query, you know that the value of [CreditLimit] = [What is the credit limit:]

I agree with mbizup, that the more practical way to do this is to leave that criteria out of your query and use an unbound textbox on your form to filter the recordset.
0
 

Author Comment

by:hallpett
ID: 39713871
You could say that my query is like this:
SELECT *
FROM yourTable
WHERE [Amount] < [What is the credit limit:]

I use this as a recordsource for a form and I want to show the value user has given when asked for [What is the credit limit:] in the heading of the form.
0
 
LVL 48

Accepted Solution

by:
Dale Fye earned 600 total points
ID: 39713878
as I said above.  get rid of the where condition in the query and use mbizups recommendation.  Put an unbound textbox in the form header.  Have the user enter the credit limit they want to use, then use either the AfterUpdate event of that textbox or a command button to set the forms Filter and FilterOn properties to filter the recordset.

If the users are not familiar with the available CreditLimit values, you might make the textbox into a combo box so that only those values that users don't type in 1000, with the lowest limit is 1500.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question