Combo box use as a Query... any help

F

fossy

I have a query (qryTrainingByTile) and a form (frmUpcomingTraining). In the
form is a combo box (Select Title) that selects the title record from a
separate table (tblJobTitles), there is also a button with a macro that open
the query when is clicked.

I need the query to use the title selected from the combo box as a criteria
when clicking the button to open the query.

Any ideas... thank you
 
M

Michel Walsh

If you open the query from the user interface, or as record source of a
form/report, or as row source of another combo box/list box, then use

FORMS!theFormNameHere!TheComboBoxNameHere

syntax as criteria. Example:

SELECT * FROM someTable WHERE someField >
FORMS!theFormNameHere!TheComboBoxNameHere



If any name if ill-formed, you need to use [ ] around it:

SELECT * FROM someTable WHERE someField > FORMS![My form one]![Select
something]


for the form My Form One and the combo box Select Something.


Hoping it may help,
Vanderghast, Access MVP
 
F

fossy

Ok... I am so lost
everytime i try any kind ot expression on the expression builder it says
sintax error
i don;t know if I'm typing it wrong some like that Help plz...

Note: the is no table for the form where the combobox is located... It is
just a form use as user interface where the user will select from the combo
box and then click on the button to bring up the results.


Michel Walsh said:
If you open the query from the user interface, or as record source of a
form/report, or as row source of another combo box/list box, then use

FORMS!theFormNameHere!TheComboBoxNameHere

syntax as criteria. Example:

SELECT * FROM someTable WHERE someField >
FORMS!theFormNameHere!TheComboBoxNameHere



If any name if ill-formed, you need to use [ ] around it:

SELECT * FROM someTable WHERE someField > FORMS![My form one]![Select
something]


for the form My Form One and the combo box Select Something.


Hoping it may help,
Vanderghast, Access MVP



fossy said:
I have a query (qryTrainingByTile) and a form (frmUpcomingTraining). In the
form is a combo box (Select Title) that selects the title record from a
separate table (tblJobTitles), there is also a button with a macro that
open
the query when is clicked.

I need the query to use the title selected from the combo box as a
criteria
when clicking the button to open the query.

Any ideas... thank you
 
M

Michel Walsh

If you are defining your query in the query designer, then you type the
criteria, in the grid, under the field (or expression) to be compared, and
at the Criteria line. The word FORMS is to be typed as it is, with the two
!, but supply your form name and your control (combo box) name.

Be sure the form is open, and the combo box has some value then, run (view
data) the query you just defined.

Should work, nothing more complex than that is involved.


Vanderghast, Access MVP



fossy said:
Ok... I am so lost
everytime i try any kind ot expression on the expression builder it says
sintax error
i don;t know if I'm typing it wrong some like that Help plz...

Note: the is no table for the form where the combobox is located... It is
just a form use as user interface where the user will select from the
combo
box and then click on the button to bring up the results.


Michel Walsh said:
If you open the query from the user interface, or as record source of a
form/report, or as row source of another combo box/list box, then use

FORMS!theFormNameHere!TheComboBoxNameHere

syntax as criteria. Example:

SELECT * FROM someTable WHERE someField >
FORMS!theFormNameHere!TheComboBoxNameHere



If any name if ill-formed, you need to use [ ] around it:

SELECT * FROM someTable WHERE someField > FORMS![My form one]![Select
something]


for the form My Form One and the combo box Select Something.


Hoping it may help,
Vanderghast, Access MVP



fossy said:
I have a query (qryTrainingByTile) and a form (frmUpcomingTraining). In
the
form is a combo box (Select Title) that selects the title record from a
separate table (tblJobTitles), there is also a button with a macro that
open
the query when is clicked.

I need the query to use the title selected from the combo box as a
criteria
when clicking the button to open the query.

Any ideas... thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top