2012-02-27 71 views
0

公式我正在開發的庫存系統,我已經開發了以下功能的紙箱和作品之間的轉換。如何申請一個彙總字段

Public Function convertQTY(ByVal units_case As Integer, ByVal quantity As QTY) As QTY 

    While quantity.pieces < 0 And quantity.cartons > 0 

     If quantity.pieces < 0 And quantity.cartons > 0 Then 
      quantity.pieces = units_case + quantity.pieces 
      quantity.cartons -= 1 
     End If 

    End While 

    If quantity.pieces >= units_case Then 

     quantity.cartons = quantity.cartons + (quantity.pieces \ units_case) 
     quantity.pieces = quantity.pieces Mod units_case 

    End If 


    Return quantity 
End Function 

例如,如果每箱單位/件是144,則上面的代碼段轉換成紙箱如果數量超過144,並且如果片是小於0,則上面的代碼從紙箱中減去1,並增加了單位每箱成片的數量。這樣的作品從未超過一箱件的總數和他們從來沒有證明是小於0

我想總結領域我水晶報表相同的效果。用於示出在每個組的末端的紙箱和片的總和。我怎樣才能做到這一點?

+0

你有沒有意識到,你不需要While循環你的代碼裏面?只需設置'quantity.cartons =(quantity.pieces \ units_case)',然後設置'quantity.pieces = quantity.pieces國防部units_case'無條件,來代替。 – 2012-02-27 15:43:19

回答

0

通過對紙箱的數量創建公式和殘片,像這樣:

Number Of Cartons:

Sum ({MyTable.Pieces})\144 

Remaining Pieces:

Sum ({MyTable.Pieces}) mod 144