Site Search:
Sign in | Join | Help

Multiple Line Items with VB Loop in eConnect

Last post 07-30-2008 12:44 PM by AshleyRP. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-30-2008 12:24 PM

    Multiple Line Items with VB Loop in eConnect

    I am having some problems getting this code to work correctly. I loop through rows in a data set where each row represents one line item for an invoice. I would like to preserve the data in the previous row when it goes on to the next. What happens now is when the code loops to the second row, the first is being overwritten with whatever is in the second. For example, if the first row contains item number 123, it initially goes in as item 123. If the second row contains item number 234, I then have 2 rows of data. Both containing item 234. If a third item contains item 345, I will then have 3 rows of data containing item 345. This data is then written into XML once the sales header is created, giving me incorrect line items in my GP invoice. I'm not sure if this is a VB or an eConnect issue, but it is driving me mad! I have attached my code below. If more is needed, just let me know, and PLEASE help. Thanks in advance!

    For Each Module1.dr In dt.Rows

    r = r + 1

    With salesLine

    Quantity = ds.Tables.Item(0).Rows(r).Item(12).ToString

    ItemNo = ds.Tables.Item(0).Rows(r).Item(13).ToString

    CustomerName = ds.Tables(0).Rows(r).Item(0).ToString

    Phone = ds.Tables(0).Rows(r).Item(10).ToString

    Shipping = ds.Tables(0).Rows(r).Item(8).ToString

    .DEFPRICING = 1

    .CUSTNMBR = "294496"

    .SOPNUMBE = SopNumber

    .AutoAssignBin = 0

    .DOCDATE = Today

    .SOPTYPE = 3

    .DOCID = "CB"

    .QUANTITY = Quantity

    .ITEMNMBR = ItemNo

    .LOCNCODE = "PORT ALLEN"

    End With

    ReDim Preserve LineItems(0 To i)

    LineItems(i) = salesLine

    i = i + 1

    Next

    Thanks!
    - Ashley -
    • 207.191.28.162
  • 07-30-2008 12:40 PM In reply to

    Re: Multiple Line Items with VB Loop in eConnect

    At the top of your code, say:

    Dim salesline as WHATEVER

    Then, in your loop, say:

    r = r + 1
    
    
    salesline = NEW  WHATEVER
    
    
    With salesline...

    Steve Gray, MCDBA
    Technical Editor
    steve@VSToolsForum.com
    • 216.64.79.2
  • 07-30-2008 12:44 PM In reply to

    Re: Multiple Line Items with VB Loop in eConnect

    You are a lifesaver! Thanks.

    Thanks!
    - Ashley -
    • 207.191.28.162
Page 1 of 1 (3 items)