Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shows .F. in the ListBox

Status
Not open for further replies.

billyng

Programmer
Dec 7, 2004
25
US
Hi folks,

I run a query and store the result into an array for the list box. If there is no result from the query, the list list box will show a line with .F.. How can I display an empty list instead of one line of .F. when the result is empty?

Thanks!

Billy
 
There are a couple ways of doing this.

One way is to check whether your query returned any results and if not then to set the rowsource of the listbox to an empty string.

Code:
SELECT * from myTable INTO ARRAY arySource
if _tally = 0
     thisform.list1.rowsource = ""
endif

The other way to accomplish this, though it has the drawback of allowing the user to select the top line in the listbox which will be empty is:

Dimension your array before the query is run and initialize the first element with an empty string...
Code:
Dimension arySource(1)
[b]arySource(1) = ""[/b]
SELECT * from myTable INTO ARRAY arySource

boyd.gif

 
Hi Billy.

How can I display an empty list instead of one line of .F. when the result is empty?

What I do is to disable the drop down list when there are no items in the array. This code goes in the refresh() method of the combo. This implies that whn you requery() the combo, you also have to refresh it.

Code:
*** First Check to see if this combo has an empty array as its RowSource
*** because if it does, we will disable it so we don't see the little
*** .F. when it is dropped down
IF This.RowSourceType = 5 AND TYPE( 'This.aContents[ 1, 1 ]' ) = 'L'
  *** We have no items, disable the combo
  This.Enabled = .F.
ELSE
  This.Enabled = .T.
ENDIF

Marcia G. Akins
 
Thankss guys. It looks so much better now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top