Information générale
Catégorie:
Gestionnaire d'écran & Écrans
>I have a grid with 2 columns that change values depending on what options the end-user has chosen. What I need to be able to do is grab all of the values listed in the first column, and stuff them into a string (X,Y,Z) or an array for later use. Here is the code I have:
Do you mean you need to save the value in the first column for each row in the grid's cursor--"grab all of the values listed in the first column?"
If so then it would be something like below:
>
>WITH ThisForm.cUtility.grdBoms.cGridList.Column1
>
> FOR lnCount = 1 TO .ControlCount
Why are you iterating through the controls in the column? You seem to only be dealing with the single default textbox (text1).
>
> lcAffectedBom = ALLTRIM(eval(.text1.ControlSource))
This is wasteful to do a FOR if you are going to have a data set of any size. Better to do something like
LOCAL lcField
lcField = (.text1.ControlSource)
...
SELECT MyGridsRecordSource
SCAN
lcAffectedBom = ALLTRIM(eval(lcField)) && Try to minimize object resolution
ENDSCAN
etc.
>
> IF ISBLANK(vp_cAffectedBoms) OR ISNULL(vp_cAffectedBoms)
> vp_cAffectedBoms = lcAffectedBom
> ELSE
> vp_cAffectedBoms = (vp_cAffectedBoms + "," + lcAffectedBom)
> ENDIF
> ENDFOR
>ENDWITH
>
>I tested this with a grid that had 5 different values in it - when it was done executing, lnCount was 3 instead of 5
.ControlCount is the number of objects in the column. A column has a header and textbox by default. Sounds like there's another control in your column? It is not the number of rows in the recordsource, which is what it seems like you want.
> and vp_cAffectedBoms was "Value1,Value1" instead of "Value1,Value2,Value3,Value4,Value5" as expected.
>
>Is there any way to first accurately count the number of objects/fields/rows in the first column, and grab and store each value?
Objects, Fields, Rows. All different things. I assume you mean row.
RECCOUNT will tell you records in a cursor. If you've done a SELECT, you'd be able to use TALLY.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement