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 REPLACEENDIF
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 E. Chrzanowski
Programmer/Analyst
Saturn (Solutions) Inc.