Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2004
    Reston, VA

    Unanswered: How to reference a listbox column in query criteria?

    I was wondering if anyone knew how to reference a specific column in a form listbox in the criteria of a query, similar to how you reference a control in the query criteria, like so:


    I typically just reference textboxes in my queries, and I know you can reference the bound column of a listbox by just using the name of the listbox like so,


    but can you reference a specific column (other than the bound column)? I tried to enter the reference the same way you would in the ControlSource of a textbox,


    but that doesn't work. Enclosing the "column" portion in brackets doesn't either. And since it doesn't recognize column names in a listbox, trying to reference the column name fails, too.

    Any ideas? Or should I just give up on my dreams and accept the fact that this is an impossibility?

    Thanks - Jeff

  2. #2
    Join Date
    Feb 2004
    I don't know if this can be done in a query? I usually do this in the code module of the form.

    This would refer to column 3 of list 8. Note count is 0 to Num of columns.

    You can apply the value to a variable:

    strListVal = Me.List8.Column(2)

    Create a Query String
    qryStr = "SELECT tableTest.ID, tableTest.Field1, tableTest.Field2, tableTest.maturity " & _
    " FROM tableTest " & _
    " WHERE (((tableTest.maturity)='" & strListVal & "'"

    Then use the query string to apply to the datasource of a form or use in a DAO or ADO recordset, or create a query.



  3. #3
    Join Date
    Apr 2004
    metro Detroit
    try setting the value of a textbox on the form to the appropriate column on the listbox, then using the textbox in the query.

  4. #4
    Join Date
    Sep 2004
    Reston, VA
    rogue - I had the answer the whole time and didn't even realize it. Thanks for the reply, that works perfectly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts