?
Solved

Show query parameter on form

Posted on 2013-12-11
5
Medium Priority
?
795 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 54

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 49

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 49

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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

862 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