Query with Combo Box Problem

G

Guest

I have a multi-line combo box on a form. I'm trying to have a button on the
form open a report whose data depends on the info in the combo box. The
record source of the report is based on a query that looks up records in a
table based on the info in one of the columns of the combo box. The criteria
I'm using in one of the fields in the query is something like this: "Like
Forms!frmX!cboName.Column(0)". The query does not like the
"...cboName.Column(0)" part. Specifically, it objects to the .column(0)
part. How do I write the criteria for the query so that I grab just 1 column
of the combo box (if possible)??

Nick
 
G

Guest

Just refer to the name of the combo box, and make sure the bound column is
the one you want to use for your filter. The value of the combo box (without
the column(X) is the value of the bound column.

If you want an exact match, use this, otherwise your Like statement:

=[Forms]![frmX]![cboName]

Question, though. When you say "multi-line combo box" do you mean that this
is a list box? If it is a list box, and not a combo box, the method of
referring to its value(s) changes drastically.
 
G

Guest

Brian,

What if the column in your combo box is not the bound column? Is there a
way to reference the other columns in a combo box from the query?

Thanks,

Jim

Brian said:
Just refer to the name of the combo box, and make sure the bound column is
the one you want to use for your filter. The value of the combo box (without
the column(X) is the value of the bound column.

If you want an exact match, use this, otherwise your Like statement:

=[Forms]![frmX]![cboName]

Question, though. When you say "multi-line combo box" do you mean that this
is a list box? If it is a list box, and not a combo box, the method of
referring to its value(s) changes drastically.

ndunwoodie said:
I have a multi-line combo box on a form. I'm trying to have a button on the
form open a report whose data depends on the info in the combo box. The
record source of the report is based on a query that looks up records in a
table based on the info in one of the columns of the combo box. The criteria
I'm using in one of the fields in the query is something like this: "Like
Forms!frmX!cboName.Column(0)". The query does not like the
"...cboName.Column(0)" part. Specifically, it objects to the .column(0)
part. How do I write the criteria for the query so that I grab just 1 column
of the combo box (if possible)??

Nick
 
G

Guest

I'm not aware of any direct way to do it, because you can't use the
..Column(x) property in the query. I would do one of two things in a query;
both involve a domain aggegate lookup:

1. A DLookup of the required field and using the combo box's value in the
Where clause.
2. A user-defined function in a global module that accepts a reference to
the combo box's value as an argument and (again, using DLookup) returns the
value of the required field.

Jim said:
Brian,

What if the column in your combo box is not the bound column? Is there a
way to reference the other columns in a combo box from the query?

Thanks,

Jim

Brian said:
Just refer to the name of the combo box, and make sure the bound column is
the one you want to use for your filter. The value of the combo box (without
the column(X) is the value of the bound column.

If you want an exact match, use this, otherwise your Like statement:

=[Forms]![frmX]![cboName]

Question, though. When you say "multi-line combo box" do you mean that this
is a list box? If it is a list box, and not a combo box, the method of
referring to its value(s) changes drastically.

ndunwoodie said:
I have a multi-line combo box on a form. I'm trying to have a button on the
form open a report whose data depends on the info in the combo box. The
record source of the report is based on a query that looks up records in a
table based on the info in one of the columns of the combo box. The criteria
I'm using in one of the fields in the query is something like this: "Like
Forms!frmX!cboName.Column(0)". The query does not like the
"...cboName.Column(0)" part. Specifically, it objects to the .column(0)
part. How do I write the criteria for the query so that I grab just 1 column
of the combo box (if possible)??

Nick
 
G

Guest

Brian,

Thanks. I would have figured that MS would have allowed the .Column(x)
property in a query by now. Oh well...

Thanks again,

Jim

Brian said:
I'm not aware of any direct way to do it, because you can't use the
.Column(x) property in the query. I would do one of two things in a query;
both involve a domain aggegate lookup:

1. A DLookup of the required field and using the combo box's value in the
Where clause.
2. A user-defined function in a global module that accepts a reference to
the combo box's value as an argument and (again, using DLookup) returns the
value of the required field.

Jim said:
Brian,

What if the column in your combo box is not the bound column? Is there a
way to reference the other columns in a combo box from the query?

Thanks,

Jim

Brian said:
Just refer to the name of the combo box, and make sure the bound column is
the one you want to use for your filter. The value of the combo box (without
the column(X) is the value of the bound column.

If you want an exact match, use this, otherwise your Like statement:

=[Forms]![frmX]![cboName]

Question, though. When you say "multi-line combo box" do you mean that this
is a list box? If it is a list box, and not a combo box, the method of
referring to its value(s) changes drastically.

:

I have a multi-line combo box on a form. I'm trying to have a button on the
form open a report whose data depends on the info in the combo box. The
record source of the report is based on a query that looks up records in a
table based on the info in one of the columns of the combo box. The criteria
I'm using in one of the fields in the query is something like this: "Like
Forms!frmX!cboName.Column(0)". The query does not like the
"...cboName.Column(0)" part. Specifically, it objects to the .column(0)
part. How do I write the criteria for the query so that I grab just 1 column
of the combo box (if possible)??

Nick
 
G

Guest

Yeah. It's all about context: Jet, DAO, ADO, etc.,etc.etc. I unsuccessfully
tried a Split in a query yesterday, and had to create a user-defined function
for that, also. It seems that where there's a will and a forum post, there's
a way...

Jim said:
Brian,

Thanks. I would have figured that MS would have allowed the .Column(x)
property in a query by now. Oh well...

Thanks again,

Jim

Brian said:
I'm not aware of any direct way to do it, because you can't use the
.Column(x) property in the query. I would do one of two things in a query;
both involve a domain aggegate lookup:

1. A DLookup of the required field and using the combo box's value in the
Where clause.
2. A user-defined function in a global module that accepts a reference to
the combo box's value as an argument and (again, using DLookup) returns the
value of the required field.

Jim said:
Brian,

What if the column in your combo box is not the bound column? Is there a
way to reference the other columns in a combo box from the query?

Thanks,

Jim

:

Just refer to the name of the combo box, and make sure the bound column is
the one you want to use for your filter. The value of the combo box (without
the column(X) is the value of the bound column.

If you want an exact match, use this, otherwise your Like statement:

=[Forms]![frmX]![cboName]

Question, though. When you say "multi-line combo box" do you mean that this
is a list box? If it is a list box, and not a combo box, the method of
referring to its value(s) changes drastically.

:

I have a multi-line combo box on a form. I'm trying to have a button on the
form open a report whose data depends on the info in the combo box. The
record source of the report is based on a query that looks up records in a
table based on the info in one of the columns of the combo box. The criteria
I'm using in one of the fields in the query is something like this: "Like
Forms!frmX!cboName.Column(0)". The query does not like the
"...cboName.Column(0)" part. Specifically, it objects to the .column(0)
part. How do I write the criteria for the query so that I grab just 1 column
of the combo box (if possible)??

Nick
 

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

Similar Threads


Top