Djblois
08-01-2007, 07:20 AM
I am trying to use Arrays to shorten my code. Here is what it looks like before the Array Loop:
PT.AddFields RowFields:=Array("Customer", "Cust#", "SlsPrsn", "Date", "Invoice#", "Product", "Item#", "Whse", "Price$", "Del")
ptNoTotal "Cust#"
ptNoTotal "SlsPrsn"
ptNoTotal "Date"
ptNoTotal "Invoice#"
ptNoTotal "Product"
ptNoTotal "Item#"
ptNoTotal "Cases"
ptNoTotal "Whse"
ptNoTotal "Price$"
ptNoTotal "Del"
This is what I tried with the Array loop:
aRowFields = Array("Cust#", "SlsPrsn", "Date", "Invoice#", "Product", "Item#", "Whse", "Price$", "Del")
PT.AddFields RowFields:=Array("Customer", "Cust#", "SlsPrsn", "Date", "Invoice#", "Product", "Item#", "Whse", "Price$", "Del")
For NoTotalRow = LBound(aRowFields, 1) To UBound(aRowFields, 1)
ptNoTotal aRowFields(NoTotalRow, 0)
Next
The first code works but the second code doesn't. It crashes on the second code. ptNoTotal is a sub that I have created with the ability to pass the rowfield name. If there is anything else you need to help just ask?
PT.AddFields RowFields:=Array("Customer", "Cust#", "SlsPrsn", "Date", "Invoice#", "Product", "Item#", "Whse", "Price$", "Del")
ptNoTotal "Cust#"
ptNoTotal "SlsPrsn"
ptNoTotal "Date"
ptNoTotal "Invoice#"
ptNoTotal "Product"
ptNoTotal "Item#"
ptNoTotal "Cases"
ptNoTotal "Whse"
ptNoTotal "Price$"
ptNoTotal "Del"
This is what I tried with the Array loop:
aRowFields = Array("Cust#", "SlsPrsn", "Date", "Invoice#", "Product", "Item#", "Whse", "Price$", "Del")
PT.AddFields RowFields:=Array("Customer", "Cust#", "SlsPrsn", "Date", "Invoice#", "Product", "Item#", "Whse", "Price$", "Del")
For NoTotalRow = LBound(aRowFields, 1) To UBound(aRowFields, 1)
ptNoTotal aRowFields(NoTotalRow, 0)
Next
The first code works but the second code doesn't. It crashes on the second code. ptNoTotal is a sub that I have created with the ability to pass the rowfield name. If there is anything else you need to help just ask?