qberta01
Programmer
- Nov 14, 2005
- 113
Hello,
I am not a FoxPro programmer, but have been given what I thought would be the simple task of creating an order by sequence in a report that is built through code. I am using version 7.....
Everything works fine until I get to the order by on the postal zone. What I would like to do in the postal zone portion is order by a bit field called renewal (in the LblData table) then the postal zone.
Please review..
* These next 40+ lines do nothing but put the data in a particular print sequence.
Wait Window 'Preparing Label Print Order
Sequence... One Moment Please' NoWait
Alter Table lbldata Add Column OrderBy I
Index On OrderId TO tmpIdx3
If File('TmpOrdBy.Dbf')
Erase TmpOrdBy.Dbf
Endif
Create Table TmpOrdBy (CustID i, OrderID i,
ProdList c(254))
Select LblData
Go Top
Private cProdCodeList, iOrderID, iSeqNbr
cProdCodeList = ''
Do While !Eof()
iOrderID = OrderID
iCustID = CustID
iCopies = Copies
DO While OrderID = iOrderID
iCopies = Max(iCopies, Copies)
cProdCodeList = cProdCodeList + Padr(Alltrim(ProdCode), 8, '.')
Skip
EndDo
cProdCodeList = Padl(Alltrim(Str(iCopies)), 3, '0') + cProdCodeList
Insert Into TmpOrdBy (CustID, OrderID, ProdList) Values (iCustID, iOrderID, cProdCodeList)
cProdCodeList = ''
Enddo
Select Custid, Orderid, ProdList, Len(Alltrim(ProdList)) From TmpOrdBy Order By 3 Into Cursor MyTemp
Select MyTemp
Set Relation To OrderID Into LblData
iSeqNbr = 0
Scan
Select LblData
iSeqNbr = iSeqNbr + 1
DO While OrderID = MyTemp.OrderID And !Eof()
Replace OrderBy With iSeqNbr
Skip
Enddo
Select MyTemp
EndScan
Select MyTemp
Set Relation To
Select LblData
Index On OrderBy To tmpIdx4
Wait Window 'Print Order Sequencing Complete. Now Gathering Address Data' NoWait
****************************************************************************************************************************
* Postal Zone Ordering
Wait Window 'Preparing Label Print Order Sequence By Postal Zone... One Moment Please' NoWait
Select LblData
If TYPE('LblData.PostalZone') = 'U'
Index On STR(Copies)+STR(OrderBy) To tmpIdxPst
Else
*Had to get a little tricky here...
*All multiples are supposed to be grouped together, then sorted by PZ...
*So we pad the index value for the zone with a space for singles.
Index On IIF(Copies>1,(IIF(Renewal = .F.,0,1)),' '+IIF(Renewal = .F.,0,1))+STR(PostalZone)+STR(Copies)+STR(OrderBy) To tmpIdxPst
EndIf
Wait Window 'Print Order Sequencing Complete. Now Gathering Address Data' NoWait
******************************************************
I get the following error:
Line Of Code.: Index On IIF(Copies>1,(IIF(Renewal = .F.,0,1)),' '+IIF(Renewal = .F.,0,1))+STR(PostalZone)+STR(Copies)+STR(OrderBy) To tmpIdxPst
Error Message: Operator/operand type mismatch.
If anyone can help I would really appreciate it! Also, please forgive the slopiness of the code.
*ENDIF
I am not a FoxPro programmer, but have been given what I thought would be the simple task of creating an order by sequence in a report that is built through code. I am using version 7.....
Everything works fine until I get to the order by on the postal zone. What I would like to do in the postal zone portion is order by a bit field called renewal (in the LblData table) then the postal zone.
Please review..
* These next 40+ lines do nothing but put the data in a particular print sequence.
Wait Window 'Preparing Label Print Order
Sequence... One Moment Please' NoWait
Alter Table lbldata Add Column OrderBy I
Index On OrderId TO tmpIdx3
If File('TmpOrdBy.Dbf')
Erase TmpOrdBy.Dbf
Endif
Create Table TmpOrdBy (CustID i, OrderID i,
ProdList c(254))
Select LblData
Go Top
Private cProdCodeList, iOrderID, iSeqNbr
cProdCodeList = ''
Do While !Eof()
iOrderID = OrderID
iCustID = CustID
iCopies = Copies
DO While OrderID = iOrderID
iCopies = Max(iCopies, Copies)
cProdCodeList = cProdCodeList + Padr(Alltrim(ProdCode), 8, '.')
Skip
EndDo
cProdCodeList = Padl(Alltrim(Str(iCopies)), 3, '0') + cProdCodeList
Insert Into TmpOrdBy (CustID, OrderID, ProdList) Values (iCustID, iOrderID, cProdCodeList)
cProdCodeList = ''
Enddo
Select Custid, Orderid, ProdList, Len(Alltrim(ProdList)) From TmpOrdBy Order By 3 Into Cursor MyTemp
Select MyTemp
Set Relation To OrderID Into LblData
iSeqNbr = 0
Scan
Select LblData
iSeqNbr = iSeqNbr + 1
DO While OrderID = MyTemp.OrderID And !Eof()
Replace OrderBy With iSeqNbr
Skip
Enddo
Select MyTemp
EndScan
Select MyTemp
Set Relation To
Select LblData
Index On OrderBy To tmpIdx4
Wait Window 'Print Order Sequencing Complete. Now Gathering Address Data' NoWait
****************************************************************************************************************************
* Postal Zone Ordering
Wait Window 'Preparing Label Print Order Sequence By Postal Zone... One Moment Please' NoWait
Select LblData
If TYPE('LblData.PostalZone') = 'U'
Index On STR(Copies)+STR(OrderBy) To tmpIdxPst
Else
*Had to get a little tricky here...
*All multiples are supposed to be grouped together, then sorted by PZ...
*So we pad the index value for the zone with a space for singles.
Index On IIF(Copies>1,(IIF(Renewal = .F.,0,1)),' '+IIF(Renewal = .F.,0,1))+STR(PostalZone)+STR(Copies)+STR(OrderBy) To tmpIdxPst
EndIf
Wait Window 'Print Order Sequencing Complete. Now Gathering Address Data' NoWait
******************************************************
I get the following error:
Line Of Code.: Index On IIF(Copies>1,(IIF(Renewal = .F.,0,1)),' '+IIF(Renewal = .F.,0,1))+STR(PostalZone)+STR(Copies)+STR(OrderBy) To tmpIdxPst
Error Message: Operator/operand type mismatch.
If anyone can help I would really appreciate it! Also, please forgive the slopiness of the code.
*ENDIF