Solved

Show query parameter on form

Posted on 2013-12-11
5
757 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 50

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 Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

856 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