FORM EVENT PRODEDURE

  • Thread starter ANDY-N via AccessMonster.com
  • Start date
A

ANDY-N via AccessMonster.com

I have a list box in a form; I would like to use a field in this list box as
a criteria for a query. What I want it to do is that when I click on the
field in list box, it would call up the query and use what I selected as the
control? I tried to point to the query to the form to get the criteria using
[forms]![formname]![fieldname] as the criteria in the query I want to run,
but that didnt work. Any suggestions?

Thanks in advance.

P.S: If I need to write an Even Procedure, how do I do that? I know to do
that for list boxes in the same form but not for list boxes in a different
form.
 
D

Dale Fye

Andy,

Does your listbox contain multiple fields? If so, and the field you want to
use in your query criteria is not the "bound column", then you will also need
to refer to the specific column (listbox columns are zero based) in the list;
something like:

Forms!FormName.ListboxControlName.Column(3)

This would return the value from the 4th column in your listbox, for the
selected record. This will not work if the listbox has multi-select set to
simple or extended.

HTH
Dale
 
A

ANDY-N via AccessMonster.com

Dale-

The list box contains multiple fields, it is unbound, multi-select is "NONE"
and only 1 column is bound. I tried what you suggested using FORMS![FORM NAME]
.NAME.COLUMN(1) in the query criteria and the query parameter, and got
"invalid bracketing of name". When I used [FORMS]![FORM NAME].[NAME].[COLUMN
(1)] the query did not find what it is looking for and prompted me to enter
manually. Is there something else that might be wrong?

Dale said:
Andy,

Does your listbox contain multiple fields? If so, and the field you want to
use in your query criteria is not the "bound column", then you will also need
to refer to the specific column (listbox columns are zero based) in the list;
something like:

Forms!FormName.ListboxControlName.Column(3)

This would return the value from the 4th column in your listbox, for the
selected record. This will not work if the listbox has multi-select set to
simple or extended.

HTH
Dale
I have a list box in a form; I would like to use a field in this list box as
a criteria for a query. What I want it to do is that when I click on the
[quoted text clipped - 8 lines]
that for list boxes in the same form but not for list boxes in a different
form.
 
D

Dale Fye

Sorry,

That should have been:

Forms![yourFormName].ListboxControlName.column(1)

as an example:

Forms!frm_myForm.lst_MyList.Column(1)

you have to replace "yourFormName" with the name of your form,
and "listboxControlName" with the name of your listbox control.

Try this. Open the form and click on one of the items in the listbox.
Now, open the immediate (debug) window and type(with appropriate
substitution):

?Forms!yourFormName.lstboxControlName.column(1)

Then do column 2, column 3, ... does it print out the values in the
selected record of the listbox?

Dale

ANDY-N via AccessMonster.com said:
Dale-

The list box contains multiple fields, it is unbound, multi-select is
"NONE"
and only 1 column is bound. I tried what you suggested using FORMS![FORM
NAME]
NAME.COLUMN(1) in the query criteria and the query parameter, and got
"invalid bracketing of name". When I used [FORMS]![FORM
NAME].[NAME].[COLUMN
(1)] the query did not find what it is looking for and prompted me to
enter
manually. Is there something else that might be wrong?

Dale said:
Andy,

Does your listbox contain multiple fields? If so, and the field you want
to
use in your query criteria is not the "bound column", then you will also
need
to refer to the specific column (listbox columns are zero based) in the
list;
something like:

Forms!FormName.ListboxControlName.Column(3)

This would return the value from the 4th column in your listbox, for the
selected record. This will not work if the listbox has multi-select set
to
simple or extended.

HTH
Dale
I have a list box in a form; I would like to use a field in this list
box as
a criteria for a query. What I want it to do is that when I click on the
[quoted text clipped - 8 lines]
that for list boxes in the same form but not for list boxes in a
different
form.
 
A

ANDY-N via AccessMonster.com

Dale-

Thanks for the help, I got it to work through another method =] thanks for
your replies.

Dale said:
Sorry,

That should have been:

Forms![yourFormName].ListboxControlName.column(1)

as an example:

Forms!frm_myForm.lst_MyList.Column(1)

you have to replace "yourFormName" with the name of your form,
and "listboxControlName" with the name of your listbox control.

Try this. Open the form and click on one of the items in the listbox.
Now, open the immediate (debug) window and type(with appropriate
substitution):

?Forms!yourFormName.lstboxControlName.column(1)

Then do column 2, column 3, ... does it print out the values in the
selected record of the listbox?

Dale
[quoted text clipped - 35 lines]
 

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