Solved

Show query parameter on form

Posted on 2013-12-11
5
746 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 49

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2007 - Want to See Hierarchy of Forms and the Controls They Contain 9 34
Server configuration for MS Access - SQL Server app 8 69
Programmer 14 47
sql statement - 9 24
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

786 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