Solved

Show query parameter on form

Posted on 2013-12-11
5
719 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
5 Comments
 
LVL 48

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 100 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 200 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 47

Expert Comment

by:Dale Fye (Access MVP)
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 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 200 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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now