make criteria look for a value on form

  • Thread starter Thread starter fossy
  • Start date Start date
F

fossy

This is my situation:

I have form (note: there is no table for the form), with a list-box
“SelectTitle†that lets you select from a table “tblJobTitlesâ€. I have a
button that will open a query “qryTrainigByTitleâ€.

What I want the process to be is:
1- Select a Title from the list box.
2- Click the button to open/run the query
3- The query will use the list box as a criteria
4- Query will return only the records that correspond to the job title.

What I have tried:

I place the following on the criteria field of the “BtTitle†column of the
query:

[Forms]![frmUpcomingTraining]![SelectTitle]

I was hoping to make the field look at the form -> listbox to get the value.
This didn’t work.


I also tried to set up a “SetTempVar†on the double click event of the
listbox as a macro.

SetTempVar ListTitle, [Forms]![frmUpcomingTraining]![SelectTitle]
OpenQuery qryTrainingByTitle, Datasheet, Edit

RunCommand Refresh
RemoveTempVar ListTitle

Then, on the criteria field of the “BtTitle†column of the query:
[TempVars]![ListTitle]

Once again, I was hoping to make the field look at the temporary variable to
get the value.
This didn’t work.

Any Help please…

I you guys are reading this forums pretty often, you will see that I try
different ways to make this work and for some reason is not working thanks
again for your help.

I donn't know if it is an easy deal tha im making it harder. Im Just so lost.
 
Your first attempt did not work because your criteria is looking at the list
box and not the item selected in the list box. One way is to put a hidden
text box on your form with its control source set to

=[SelectTitle].ItemData([SelectTitle].ListIndex)

and then change your criteria in the query to

[Forms]![frmUpcomingTraining]![HiddenTextBoxName]
 
It is working halfway... i don't know if i did something wrong. When i select
an item from the list, it places a the ID number of the title not the actual
word i.e.

K value
1 operator
2 CEO

it is placing the primary key #... any suggestions

Dennis said:
Your first attempt did not work because your criteria is looking at the list
box and not the item selected in the list box. One way is to put a hidden
text box on your form with its control source set to

=[SelectTitle].ItemData([SelectTitle].ListIndex)

and then change your criteria in the query to

[Forms]![frmUpcomingTraining]![HiddenTextBoxName]

fossy said:
This is my situation:

I have form (note: there is no table for the form), with a list-box
“SelectTitle†that lets you select from a table “tblJobTitlesâ€. I have a
button that will open a query “qryTrainigByTitleâ€.

What I want the process to be is:
1- Select a Title from the list box.
2- Click the button to open/run the query
3- The query will use the list box as a criteria
4- Query will return only the records that correspond to the job title.

What I have tried:

I place the following on the criteria field of the “BtTitle†column of the
query:

[Forms]![frmUpcomingTraining]![SelectTitle]

I was hoping to make the field look at the form -> listbox to get the value.
This didn’t work.


I also tried to set up a “SetTempVar†on the double click event of the
listbox as a macro.

SetTempVar ListTitle, [Forms]![frmUpcomingTraining]![SelectTitle]
OpenQuery qryTrainingByTitle, Datasheet, Edit

RunCommand Refresh
RemoveTempVar ListTitle

Then, on the criteria field of the “BtTitle†column of the query:
[TempVars]![ListTitle]

Once again, I was hoping to make the field look at the temporary variable to
get the value.
This didn’t work.

Any Help please…

I you guys are reading this forums pretty often, you will see that I try
different ways to make this work and for some reason is not working thanks
again for your help.

I donn't know if it is an easy deal tha im making it harder. Im Just so lost.
 
I fixed it!!!!!!

on the list box, when i made it look for the data it was looking for the
PK... now i changed it to column 2 (actual Data) and tada!!! there is the
value...thanks foryou help

fossy said:
It is working halfway... i don't know if i did something wrong. When i select
an item from the list, it places a the ID number of the title not the actual
word i.e.

K value
1 operator
2 CEO

it is placing the primary key #... any suggestions

Dennis said:
Your first attempt did not work because your criteria is looking at the list
box and not the item selected in the list box. One way is to put a hidden
text box on your form with its control source set to

=[SelectTitle].ItemData([SelectTitle].ListIndex)

and then change your criteria in the query to

[Forms]![frmUpcomingTraining]![HiddenTextBoxName]

fossy said:
This is my situation:

I have form (note: there is no table for the form), with a list-box
“SelectTitle†that lets you select from a table “tblJobTitlesâ€. I have a
button that will open a query “qryTrainigByTitleâ€.

What I want the process to be is:
1- Select a Title from the list box.
2- Click the button to open/run the query
3- The query will use the list box as a criteria
4- Query will return only the records that correspond to the job title.

What I have tried:

I place the following on the criteria field of the “BtTitle†column of the
query:

[Forms]![frmUpcomingTraining]![SelectTitle]

I was hoping to make the field look at the form -> listbox to get the value.
This didn’t work.


I also tried to set up a “SetTempVar†on the double click event of the
listbox as a macro.

SetTempVar ListTitle, [Forms]![frmUpcomingTraining]![SelectTitle]
OpenQuery qryTrainingByTitle, Datasheet, Edit

RunCommand Refresh
RemoveTempVar ListTitle

Then, on the criteria field of the “BtTitle†column of the query:
[TempVars]![ListTitle]

Once again, I was hoping to make the field look at the temporary variable to
get the value.
This didn’t work.

Any Help please…

I you guys are reading this forums pretty often, you will see that I try
different ways to make this work and for some reason is not working thanks
again for your help.

I donn't know if it is an easy deal tha im making it harder. Im Just so lost.
 

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

Back
Top