passing list box value to query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using A2002. I have a list box with two columns (one hidden). The user
selects an item and then the VIEW command button shows. The ONCLICK event of
the the VIEW command button outputs a query to excel.

I am trying to get the value of the hidden column passed to the query. I
have placed a msg box prior to running the query and can see the value I
want, however when I use the same syntax in the query, I receive an error.

Can someone help me with the syntax? Error in the query is...
Undefined function
'[Forms]![frm_Select_Responsibility_Export].[lst_Functional_Block]' in
expression.

Msgbox code that displays the value correctly prior to running the query.
Msgbox
[Forms]![frm_Select_Responsibility_Export].[lst_Functional_Block].Column(1)


The query field is called "Responsibility" and is populated in the table by
an option group. The values are 1,2 or 3.

Query criteria syntax that produces the error.
[Forms]![frm_Select_Responsibility_Export].[lst_Functional_Block].Column(1)


Any assistance you can provide is appreciated.
 
Hi,
You cannot use the Column property in a query. You have to write a function that will
return the column value to your query.
Something like:

Public Function GetColumnValue As Integer
GetColumnValue = [Forms]![frm_Select_Responsibility_Export].[lst_Functional_Block].Column(1)
End Function

Then use the function as criteria
 
Back
Top