Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Listbox reporting improper Listcount.
Message
From
02/11/2005 08:41:30
Diran Nazarian
Alion Science and Technology
Annapolis, Maryland, United States
 
 
To
01/11/2005 14:58:41
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows 2000 SP4
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01062256
Message ID:
01064434
Views:
13
I will try your cursor suggestion Tamar and get back to you.

A way of recreating the same flaw that I had is to do the following:

I created a table called Test that has 2 fields. Tag c(1) and Item c(35)

In my form's init event I have the code:
PUBLIC lc_items
PUBLIC lc_list

lc_items = 'test.tag + "|" + test.item'
lc_list = EVALUATE(lc_items)
I add a listbox to the form (lstList).

I add a command button to the form (cmdPopulate) which will populate the table with data as well as setup the listbox to retrieve data from the table and place it into the list.
Local ln_x
local ln_i

If !USed('test')
  USE test IN 0
ENDIF

for ln_i = ThisForm.lstList.LISTCOUNT+1 to 1000
  Insert into test (tag, item) values (" ", "Item Number" + STR(ln_i))
endfor

For ln_x = 1 to 10000
	Insert into test (tag, item) values ("X","Junk Data" + STR(ln_x))
Endfor

set filter to test.item = "Item Number"

ThisForm.lstList.controlsource = lc_list
ThisForm.lstList.rowsourcetype = 6
ThisForm.lstList.RowSource = lc_items

WAIT WINDOW "Listcount after adding items to the table: " + STR(ThisForm.lstList.LISTCOUNT)
I then added another command button (cmdAdd) that will add a record to the table.
Insert into test (tag, item) values (" ", "Item Number" + STR(ThisForm.lstList.LISTCOUNT+1))
Thisform.lstList.REQUERY
Thisform.lstList.SETFOCUS
This.SETFOCUS

Wait WINDOW "Listcount after an item was inserted into the table: " + str(ThisForm.lstList.LISTCOUNT)
I then added the final command button (cmdDelete) that will delete the selected record from the table.
local ln_Deleted
ln_Deleted = SET("DELETED")

SET DELETED ON

DELETE
PACK

ThisForm.lstList.REQUERY
ThisForm.lstList.SETFOCUS
THIS.SETFOCUS
WAIT WINDOW "ListCount after Deleting: " + STR(ThisForm.lstList.LISTCOUNT)

SET DELETED &ln_Deleted
Now when you execute this form it will show you the listcount when the items are in the table. The initial listcount will be 1000 which is the filtered records from the table. Now whenever you add an item to the table (after it exceeds 1000) notice the listcount property.

To receive a realistic listcount property you have to delete items until it reaches <= 1000 records.

I hope this helps all to see the problem that I have been encountering.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform