Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2002
    Posts
    44

    Unanswered: Displaying a label or text box on top of a list box

    I have a listbox where I am displaying the results of a query based on user inputs to the form.

    If the query comes up empty I would like to display in large letters on top of the listbox "No results to display"

    however, I can't seem to get a label or a textbox to display in front of the listbox, even using the "bring to front" on the design view...

    any suggestions?

  2. #2
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120
    Try setting the label's visible property to = False.

    Then code it to Visible = True upon your condition.

    Michael
    Last edited by mrabrams; 05-03-02 at 12:17.

  3. #3
    Join Date
    Mar 2002
    Posts
    192
    use a message box OR..
    set (in code) the rowsource of the list box to "Value List" and set "No records to show" as a value in your row source.
    When you do a search again you'll need to reset the rowsource to your original query.

  4. #4
    Join Date
    Apr 2002
    Posts
    44
    thanks for the inputs...couldn't get those suggestions to do what I needed.


    Because
    1) even if the label is visible, it won't appear on TOP of the listbox.
    2) I couldn't set the first row to "No Records" because the listbox was a 10 column list box, so I needed the message to display across all of the columns..

    The only way I ended up making it work, was to create a label, with a white background and a sunken special effect that was the same size as the Listbox (basically so it would look identical to the listbox) and then if there were no results, just hide the listbox, and display the label, otherwise, show the listbox....


    I was hoping there would be a more "elegant" solution, but I guess sometimes you gotta do whatever it takes..


    Thanks for the inputs, though...

  5. #5
    Join Date
    Mar 2002
    Posts
    192
    It does work.

    Set the "Row Source Type" to "value list".
    Set the "Row Source" to the values you want to see (using code).

  6. #6
    Join Date
    Apr 2002
    Posts
    44
    I see what you are saying....change the rowsourcetype with each iteration of the query...but then I get into other problems, because I have an onclick event on the listbox that grabs more details of that particular record, so I would have to create another check to see if the value of the listbox was "No Results"...anyway, problem is worked around now anyway....thank you.

  7. #7
    Join Date
    Mar 2002
    Posts
    192
    for future reference... The check can be done in code if needed. And its not really a problem. only use it when your query returns .eof. otherwise use the normal rowsource. The code for the check can probably be completed in 1 inline if then else statement even.

Posting Permissions

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