>I have a xtab query myself. I'm trying to limit the number of fields in a report to 16 the 1st field always. and loop back every 15 of the rest. Also I would like to break the loops (a do while and a for loop), when there is no more data. Here's what I have so far:
>
>SELECT xtab
>GO TOP
>lnFieldTot = 2
>DO WHILE !EOF()
>FOR lnFCnt = 1 TO 15
>SELECT xtab
>lcFName = FIELD(lnFieldTot)
>lcFCnt = STR(lnFCnt)
>IF lnFCnt < 10
>lcATAFName = "ATA_Report.project"+RIGHT(lcFCnt,1)
>ELSE
>lcATAFName = "ATA_Report.project"+RIGHT(lcFCnt,2)
>ENDIF
>IF lnFCnt = 1
>SELECT ATA_Report
>GO BOTTOM
>APPEND BLANK
>REPLACE ATA_Report.ata WITH xtab.exp_1
>ENDIF
>IF !EMPTY(lcFName)
>lnATAFValue = EVAL('xtab.'+lcFName)
>lcATAFValue = STR(lnATAFValue)
>SELECT ATA_Report
>GO BOTTOM
>REPLACE &lcATAFName WITH TRIM(lcATAFValue)
&& WILL NOT DO REPLACE>ENDIF
>lnFieldTot = lnFieldTot + 1
>IF lnFCnt = 15
>lnFCnt = 0
>ENDIF
>IF lnFieldTot > FCOUNT()
>llEnd = .T.
>EXIT
>ENDIF
>ENDFOR
>SELECT xtab
>SKIP
>IF EOF()
>IF!llEnd
>GO TOP
>ELSE
>EXIT
>ENDIF
>ENDIF
>ENDDO
>
>TIA
Perry,
I'm not sure I understood correctly but could this be what you want :
select xtab
lnNeededCopies = ceiling((fcount()-1)/15)
for ix = 1 to lnNeededCopies
lcFields = field(1)
for kx=(ix-1)*15+1+iif(ix=1,1,0) to min(ix*15,fcount())
lcFields = lcFields + "," + field(kx)
endfor
select &lcFields from xtab ;
into table ("xtab"+padl(ix,3,"0"))
use in ("xtab"+padl(ix,3,"0"))
select xtab
endfor
Cetin