proper bracketing to get combo column into a query

A

asc4john

I am trying to get the text value from a combobox into a query where
clause like so

Like "*" & Chr(34) & [Forms]![frmItemTypes]![cboItemDivision].
[Column(1)] & Chr(34)
but nothing works. This works but only for numbers [Forms]!
[frmItemTypes]![cboItemDivision].
How do I bracket for text from columns in the combo box?
 
P

pietlinden

I am trying to get the text value from a combobox into a query where
clause like so

Like "*" & Chr(34) & [Forms]![frmItemTypes]![cboItemDivision].
[Column(1)] & Chr(34)
but nothing works. This works but only for numbers [Forms]!
[frmItemTypes]![cboItemDivision].
How do I bracket for text from columns in the combo box?

[FieldName] LIKE '*" & Forms!MyForm!cboItemDivision & "*'"

Open is single quote then asterisk. Close is the opposite.
 
A

asc4john

I am trying to get the text value from a combobox into a query where
clause like so
Like "*" & Chr(34) & [Forms]![frmItemTypes]![cboItemDivision].
[Column(1)] & Chr(34)
but nothing works. This works but only for numbers [Forms]!
[frmItemTypes]![cboItemDivision].
How do I bracket for text from columns in the combo box?

[FieldName] LIKE '*" & Forms!MyForm!cboItemDivision & "*'"

Open is single quote then asterisk. Close is the opposite.


[Forms]![frmItemTypes]![cboItemDivision] seems to refernce column(0)
which is a number, I need column(1) which is text
So ItemDivision.name LIKE "*" & [Forms]![frmItemTypes]!
[cboItemDivision].column(1) is what I need
But putting [Forms]![frmItemTypes]![cboItemDivision].column(1) in
without [] gives an "unrecognized function" error and with [] gives a
request to Enter Parameter Value.
 
D

Douglas J. Steele

Unfortunately, you can't use the Column property in a query.

One option you could try would be to create a function that returns the
value of the 2nd column:

Function ReturnSecondColumn(MyCombo As Combobox) As String

ReturnSecondColumn = MyCombo.Column(1)

End Function

and then use that function in your query:

Like Chr$(34) & "*" &
ReturnSecondColumn([Forms]![frmItemTypes]![cboItemDivision]) & Chr$(34)
 

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