Vous êtes sur la page 1sur 4

Attribute VB_Name = "ACCmod" Option Explicit 'option variable for accpack Public caBytDuplicate1 As Byte 'Don't allow duplicate

entries in rec eipt and payment Public caBytShow2 As Byte 'While making Receipt / Payment show corresponding Dr, Cr / Income, Expense heads only. (Don't tick it if you want to show all the heads) Public caBytallow3 As Byte 'Never allow if receipt / payment mor e than balance Public caBytsales4 As Byte 'Don't allow sales entry if balance i s more than credit limit Public caAfterSave As Byte 'After transaction record saved/ cle ar movenext moveprevious 'option variable for accpack end here Dim lngLastVno As Long Public Function updateHeads(xChanged As Boolean, Newhead _ As Long, Newamount As Single, Optional Oldhead As Long, _ Optional oldAmount As Single, Optional onDel_8 As Byte) As Boolean If onDel_8 = 8 Then 'deleting DB.Execute "update zheads set clobal = clobal - " & Newamount & " where code =" & Newhead updateHeads = True Exit Function End If Select Case xChanged Case True DB.Execute "update zheads set clobal = clobal - " & oldAmount & " where code =" & Oldhead DB.Execute "update zheads set clobal = clobal + " & Newamount & " where code =" & Newhead Case False DB.Execute "update zheads set clobal = clobal + " & Newamount & " where code =" & Newhead End Select updateHeads = True End Function Public Function updateGroups(xChanged As Boolean, Newgrp As String, _ Newamount As Single, Optional Oldgrp As String, _ Optional oldAmount As Single, Optional onDel_8 As Byte) As Boolean Exit Function If onDel_8 = 8 Then 'deleting DB.Execute "update zgroup set bal = bal - " & Newamount & " where gname ='" & Newgrp & "'" Exit Function updateGroups = True End If Select Case xChanged Case True DB.Execute "update zgroup set bal = bal - " & oldAmount & " where gname ='" & Ol dgrp & "'" DB.Execute "update zgroup set bal = bal + " & Newamount & " where gname ='" & Ne wgrp & "'" Case False DB.Execute "update zgroup set bal = bal + " & Newamount & " where gname ='" & Ne wgrp & "'" End Select

updateGroups = True End Function Public Function TransactionFilesVno(vtypeXX As String) As Long Dim Xcmd As New ADODB.Command Dim Xpar As New ADODB.Parameter Dim Xrst As New ADODB.Recordset Xcmd.CommandText = "zq7" Xcmd.CommandType = adCmdStoredProc Set Xpar = Xcmd.CreateParameter("vxx", adVariant, adParamInput) Xpar.Value = vtypeXX Xcmd.Parameters.Append Xpar Set Xcmd.ActiveConnection = DB Set Xrst = Xcmd.Execute If IsNull(Xrst.Fields(0)) = True Then lngLastVno = 1 Else lngLastVno = Xrst.Fields(0) + 1 End If Xrst.Close TransactionFilesVno = lngLastVno Exit Function End Function Public Function GetCaOptions() As Boolean Dim rs As New ADODB.Recordset With rs .Open "select * from zopt order by keyno", DB, adOpenForwardOnly, adLockReadOnly caBytDuplicate1 = .Fields("keyvalue") .MoveNext caBytShow2 = .Fields("keyvalue") .MoveNext caBytallow3 = .Fields("keyvalue") .MoveNext caBytsales4 = .Fields("keyvalue") .MoveNext caAfterSave = .Fields("keyvalue") .Close Set rs = Nothing End With End Function Public Function SetCaOptions() As Boolean Dim rs As New ADODB.Recordset With rs .Open "select * from zopt order by keyno", DB, adOpenDynamic, adLockPessimistic .Update "keyvalue", caBytDuplicate1 .MoveNext .Update "keyvalue", caBytShow2 .MoveNext .Update "keyvalue", caBytallow3 .MoveNext .Update "keyvalue", caBytsales4 .MoveNext .Update "keyvalue", caAfterSave .Close Set rs = Nothing

End With End Function Public Function UpdateBillwise(acccode As Long, TotAmt As Single) As Boolean Exit Function If TotAmt < 0 Then TotAmt = TotAmt * -1 Dim rr As New ADODB.Recordset With rr .Open "select * from zbilldet where accode =" _ & acccode & " and btype ='r' and balance > 0 order by billdate", DB, adOpenDynam ic, adLockOptimistic Do While .EOF = False If .Fields("balance") >= TotAmt Then .Update ("ramount"), .Fields("ramount") + TotAmt .Update ("balance"), .Fields("amount") - .Fields("ramount") .Close Set rr = Nothing Exit Do Else .Update ("ramount"), .Fields("ramount") + .Fields("balance") TotAmt = TotAmt - .Fields("balance") .Update ("balance"), .Fields("amount") - .Fields("ramount") End If .MoveNext Loop End With End Function Public Function ReverseUpdateBillwise(acccode As Long, TotAmt As Single) As Bool ean Exit Function If TotAmt < 0 Then TotAmt = TotAmt * -1 Dim rr As New ADODB.Recordset With rr .Open "select * from zbilldet where accode =" _ & acccode & " and btype ='r' order by billdate", DB, adOpenDynamic, adLockOptimi stic Do While .EOF = False If .Fields("ramount") >= TotAmt Then .Update ("ramount"), .Fields("ramount") - TotAmt .Update ("balance"), .Fields("amount") - .Fields("ramount") .Close Set rr = Nothing Exit Do Else If .Fields("ramount") > 0 Then TotAmt = TotAmt - .Fields("balance") .Update ("ramount"), 0 '.Fields("ramsount") - .Fields("balance") .Update ("balance"), .Fields("amount") - .Fields("ramount") End If End If .MoveNext Loop End With End Function Public Function giveAccountGroup(acCode As Long) As String Dim rs As New ADODB.Recordset

With rs .Open "select group from zheads where code =" & acCode, DB, adOpenForwardOnly, a dLockReadOnly giveAccountGroup = .Fields(0) .Close Set rs = Nothing End With End Function 'Shell "c:\command.com /c type c:\billtext.txt > prn

Vous aimerez peut-être aussi