Syntax for combo box column item

G

Guest

I've referred to a combo box's primary column in a query before
([Forms]![FormName]![ComboBoxControl]) but not with a column other than the
primary one. What is the syntax? E.g., I want to refer to column 7 but
these syntaxes are failing in one way or another:

[Forms]![FormName]![ComboBoxControl].(6)
[Forms]![FormName]![ComboBoxControl]!(6)
[Forms]![FormName]![ComboBoxControl].[6]

I'm sure i'm almost there, right? :)
 
A

Allen Browne

The syntax would be:
[Forms]![FormName]![ComboBoxControl].Column(6)

But no guarantees that this will work as expected in the context of a query.
 
G

Guest

I'm getting:

undefined function '[Forms]![FormName]![ComboBoxControl].Column' in expression

AGH!

Allen Browne said:
The syntax would be:
[Forms]![FormName]![ComboBoxControl].Column(6)

But no guarantees that this will work as expected in the context of a query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

KitCaz said:
I've referred to a combo box's primary column in a query before
([Forms]![FormName]![ComboBoxControl]) but not with a column other than
the
primary one. What is the syntax? E.g., I want to refer to column 7 but
these syntaxes are failing in one way or another:

[Forms]![FormName]![ComboBoxControl].(6)
[Forms]![FormName]![ComboBoxControl]!(6)
[Forms]![FormName]![ComboBoxControl].[6]

I'm sure i'm almost there, right? :)
 
A

Allen Browne

Yes, that sounds familiar when you try that in a query.

Whatever table serves as the RowSource for the query, try adding that table
to the query. You can then specify the criteria under the actual field from
that table instead of having to try to read the Column of the combo.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

KitCaz said:
I'm getting:

undefined function '[Forms]![FormName]![ComboBoxControl].Column' in
expression

AGH!

Allen Browne said:
The syntax would be:
[Forms]![FormName]![ComboBoxControl].Column(6)

But no guarantees that this will work as expected in the context of a
query.


KitCaz said:
I've referred to a combo box's primary column in a query before
([Forms]![FormName]![ComboBoxControl]) but not with a column other than
the
primary one. What is the syntax? E.g., I want to refer to column 7
but
these syntaxes are failing in one way or another:

[Forms]![FormName]![ComboBoxControl].(6)
[Forms]![FormName]![ComboBoxControl]!(6)
[Forms]![FormName]![ComboBoxControl].[6]

I'm sure i'm almost there, right? :)
 
V

Van T. Dinh

Try:

Eval("[Forms]![FormName]![ComboBoxControl].Column(6)")

in Query / SQL. This assumes that the Form and Column 7 of the selected row
in the ComboBox has a valid value.

HTH
Van T. Dinh
MVP (Access)
 
G

Guest

Just the thing I needed! Thanks!

Van T. Dinh said:
Try:

Eval("[Forms]![FormName]![ComboBoxControl].Column(6)")

in Query / SQL. This assumes that the Form and Column 7 of the selected row
in the ComboBox has a valid value.

HTH
Van T. Dinh
MVP (Access)



KitCaz said:
I'm getting:

undefined function '[Forms]![FormName]![ComboBoxControl].Column' in expression

AGH!
 
G

Guest

I can see the value of your suggestion. In this case, though, I do need to
refer to the combo box column because I need to know what choice the user has
made in that control.

Van T. Dinh's suggestion worked like a charm in this case. Thank you very
much for your help!

Allen Browne said:
Yes, that sounds familiar when you try that in a query.

Whatever table serves as the RowSource for the query, try adding that table
to the query. You can then specify the criteria under the actual field from
that table instead of having to try to read the Column of the combo.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

KitCaz said:
I'm getting:

undefined function '[Forms]![FormName]![ComboBoxControl].Column' in
expression

AGH!

Allen Browne said:
The syntax would be:
[Forms]![FormName]![ComboBoxControl].Column(6)

But no guarantees that this will work as expected in the context of a
query.


I've referred to a combo box's primary column in a query before
([Forms]![FormName]![ComboBoxControl]) but not with a column other than
the
primary one. What is the syntax? E.g., I want to refer to column 7
but
these syntaxes are failing in one way or another:

[Forms]![FormName]![ComboBoxControl].(6)
[Forms]![FormName]![ComboBoxControl]!(6)
[Forms]![FormName]![ComboBoxControl].[6]

I'm sure i'm almost there, right? :)
 

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