Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004

    Unanswered: ListBox, BoundColumn, and a Query

    I have a listbox with 4 columns, 2nd & 3rd visible. Only one row. I need the value from the 4th column in my query. I tried using listbox.column(3,0), but the query won't accept it, as far as I know. So I set boundColumn = 4 and used lstbox.value. It only works when I click on the listbox first otherwise I get a null error. I have to click on it also when I update the listbox or I'll get the old value. I've tried setting the focus right before I run the query(which is the control source for another listbox) and that doesn't work. So I can get it to work, but only when I manually click on the listbox before the query is run. It seems like all I should have to do is set the focus in the code, but that isn't working. Any help is appreciated. Thanks.

  2. #2
    Join Date
    Oct 2001
    Try listbox.column(3) for the fourth column's value.

    Some properties and values are not accessable in queries - in that case you need to use a function to return the value as shown below:

    SELECT Table1.BlahBlah, GrabListValue() AS ListBoxValue
    FROM Table1;

    Function in module:
    Function GrabListValue() As String
    On Error GoTo PROC_ERR

    GrabListValue = [Forms]![Form1]![listbox].column(3)

    Exit Function

    MsgBox Err.Description
    Resume PROC_EXIT

  3. #3
    Join Date
    Jan 2004
    The function suggestion works nice. Thank you very much.

Posting Permissions

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