Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
COMBO
Message
From
30/05/1997 13:11:57
Bob Lucas
The WordWare Agency
Alberta, Canada
 
 
To
29/05/1997 12:39:16
Holly Clawson
Travelcenters of America
Westlake, Ohio, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Re: COMBO
Miscellaneous
Thread ID:
00034077
Message ID:
00034276
Views:
32
> Gotfocus
>
>if !mnew
>
> select compname ;
> from custmast ;
> where customer.parentno = custmast.custno into array aParentno
>else
> select compname ;
> from custmast ;
> into array aParentno
>
> gnCount = _TALLY
> gcName = CUSTMAST.COMPNAME
>
> IF ASCAN(aPARENTNO, gcName) = 0 && Search for company
> *** Company not found-add it ***
> DIMENSION aPARENTNO[gnCount+1]
> = AINS(aPARENTNO, gnCount+1)
> APARENTNO(GNCOUNT+1)=GCNAME
> endif
> THISFORM.REFRESH
>endif
>
>The combo is set to array with the rowsouce = to the array.
>All of this works, The problem is that when I pull down the combo it only displays the first record of the array. like I said I can debug and see all of the records that are displayed in the Array.
>
>Holly


Holly, Here is how I would change your code. Since this code is in the gotfocus event, it means that you are reloading the array each time the user enters the combo box.

Init event of the form set
Dimension aParentno[1]

select compname ;
from custmast ;
where customer.parentno = custmast.custno into array aParentno

*--- change the form init
*-- note that the array you are using is local and not persistent during the life of the form. I would recommend using a form property that
*-- is an array. As well, when the combo is created (during th form load, it's recordsource, aParentno, does not exist.
*-- I suspect you have made aParentno a global array. If not, leave the recordsource property blank in the combo setup.
*-- add this line to the init

*-- if recordsource is not defined yet do the next line
thisform.cboCombo.recordsource = "aparentno"


thisform.cboCombo.requery()

*-- this will load the combo box with all the data from the above query

Gotfocus of the combo box:


if !mnew

select compname ;
from custmast ;
where customer.parentno = custmast.custno into array aParentno
else
select compname ;
from custmast ;
into array aParentno

gnCount = _TALLY
gcName = CUSTMAST.COMPNAME

IF ASCAN(aPARENTNO, gcName) = 0 && Search for company
*** Company not found-add it ***
DIMENSION aPARENTNO[gnCount+1]
= AINS(aPARENTNO, gnCount+1)
APARENTNO(GNCOUNT+1)=GCNAME
endif

THISFORM.REFRESH
endif

*-- now that you have refreshed the array, you must 'refresh' the combo box. However, refresh is not really
*-- the right word. You really need to reload the combo box to match the current array data. Because the
*-- recordsource is aParentno you must do the following again (like in the init)

this.requery()


Bob
Previous
Reply
Map
View

Click here to load this message in the networking platform