Query By Form

Gutts

New member
Local time
Today, 12:47
Joined
Nov 12, 2007
Messages
3
Hello guys

I have a question that's probably a beginers one but i looked all over the forum and the examples and couldnt find any solution. If you could help it would be great. Here we go:

Lets say we have 1 form, a table and a query. On the form there is a combo box named combofield with values 1, 2 and 3. Table has this fields:

name
f1
f2
f3

query looks like this:

field from some other table 1
field from some other table 2
name
f1

What i need to do is when i chose 2 from combo box and press some button is to get this query:

field from some other table 1
field from some other table 2
name
f2

and same thing for value 3 from combo box

field from some other table 1
field from some other table 2
name
f3

I know i could just make 3 queries and just pick one based on the values in the combo but in reality i have some 15 fields that i need to chose from.

Tnx in advance
 
set the query criteria for the field name you want ot find
=forms!yourformname.yourcomboboxname

in the after update of the combobox you should do a requery of the form..
 
tnx for the quick reply m8. I saw that solution in one of the threads but its not working for some reason. I think I'm missing something easy but not sure. This is what i have and what i get

query
=====
field: f1
table: tab1
show: yes
criteria: =forms!yourformname.yourcomboboxname

error: this expression is typed incorrectly (its not, checked quite a few times) or it is to complex to be evaluated.
The values in combo box are f1;f2;f3. When i pass numerical value from another combo it passes but i do not get what i need ofc. So its some type mistake. Any thoughts?
 
If what you want is for the query to return field f1, f2 or f3 based on user-selection in the combo box, you have to have three separate queries. You can't change the fields to return at will in a query.

Alternatively, you can use VBA code to build/edit the SQL statement of a query on the fly based on the combo box selection.

^
 
Last edited:
I was expecting some answer like that tbh :( I cant believe that theres no simpler solution for that. Well ok.. of to vba coding :)

Tnx again guys
 

Users who are viewing this thread

Back
Top Bottom