Set field in query as value in list box in form

gneissgirl

Access Extreme Novice
Local time
Today, 03:48
Joined
Jun 21, 2005
Messages
5
:confused: I've tried everything I can possibly think of to get this to work. I've also looked at other threads and I still couldn't get this to work. The code for the list box in my form is Forms!Display_Engineering_Jobs_Report_Inputs!Report_Column1. I am trying to set the value in this list box as the input for the field on my query. This value also corresponds to a heading within a table I have. The information under the heading in this table is what I am trying to show in the query. Please help! Also, I'm pretty new to Access, so explain it as if you were writing a page in "Access for Dummies." Thanks!
 
Hi
I'm not sure I understand your question 100%, but if I understand it correctly, you want to select a value from a listbox on a form. The value in the listbox is passed through to a query as the criteria for a certain field.

If that is the case, then in your query design screen, under the column heading that you wish to set the crtieria for, enter criteria using the following syntax:

[Forms]![YourFormName].[YourListBoxName]

Check you have the correct syntax, the correct form name and the correct name of the list box.

If I have mis-read your question, post a reply with some more information.

HTH, Andrew
 
Last edited:
Yeah, you understood the question correctly. I entered the info. you gave me under the criteria, but it asks for a field from the field list for my table. That is what I am trying to specify using the list box. I tried entering what you gave me as the field, but it asked for parameter value. Any ideas?
 
Once you have selected an item in your list box on your form, are you clicking a button on the form to open the query? Or are you manually opening the query?
 
2 things to check on.

1: is the column you are passing from your list box the same format as the field you are trying to query off of (i.e.: are you passing text from your listbox to a text field in the query, or are you passing an integer from the listbox to a date on the query, etc.)

2: did you spell the name of the form, control and field correctly? If your form is titled "SpellingBee" and your list box is "ListOfWords" then your code here should be:

Code:
[Forms]![SpellingBee]![ListOfWords]

Keep in mind also that in this case the list box is simply passing whatever it it's bound column (normally the first column unless you changed it). In other words, if you are trying to pass column #2 and your bound column is column #1, you are actually passing the value from column #1 despite your best intentions. Try changing your bound column if this doesn't screw up your list box, otherwise, check out performing the query in vb or another way of passing the correct value (i.e.: create a text box which stores the value of the correct column and then set the query to get it's value from the text bod). If that didn't confuse you enough, let me know.

If you don't konw about the bound column setting than let us know and we can try to help you further.
 
I have no clue about bound column setting. I am getting slightly closer, however. When I select a table heading in my list box, it fills in every field within the query with that table heading name. This is what it's doing:
List box = DATEREQUIRED
Query looks like this:
Expr1
DATEREQUIRED
DATEREQUIRED
DATEREQUIRED
.
.
.

This is an example of what I want it to do:
List box = DATEREQUIRED
Query looks like this:
DATEREQUIRED
9/20/05
10/15/05
11/5/05
8/16/06
.
.
.
Where the dates are listed in the table under the heading of DATEREQUIRED.
Help?
 
I am trying to set the value in this list box as the input for the field on my query. This value also corresponds to a heading within a table I have.
You can't let the user decide, on the fly, which table field to display in the query results when a query is run. You must decide which field(s) to display when the query is built.

[Forms]![YourFormName]![YourListBoxName] is used only as a criterion for a field, that is, the field value to be returned by the query.
.
 
Bugger. That's precisely what I wanted to do. Oh well. People will just have to do it the hard way.

Thanks!
 

Users who are viewing this thread

Back
Top Bottom