January 2000
Intermediate to advanced
672 pages
21h 46m
English
Now we are ready to add and edit transactions. The natural thing to do is to allow a double-click on a transaction to lead to a special dialog for editing. This should perform the necessary validation to ensure that the transaction balances before the dialog is closed, and, if there is a change, it should update all of the current views. We’ve built a pair of dialogs in VB: one to edit transactions and the other (called from it) to edit individual line items. Figure 7.3 shows the transaction dialog.
![]() |
The code to edit the transaction is exposed as a method of the form as follows:
Public Function Edit(index As Integer) As Boolean 'returns true is the transaction was successfully edited Dim i As Integer Dim linecount As Integer Set tran = frmMain.BookServer.getTransaction(index) 'display the transaction details lblTranIndex.Caption = Str(index) txtDate.text = FormatDateTime(tran.getCOMDate) txtComment.text = tran.getComment linecount = tran.getLineCount grdItems.rows = linecount + 1 For i = 0 To linecount - 1 grdItems.TextMatrix(i + 1, 0) = tran.GetAccount(i) grdItems.TextMatrix(i + 1, 1) = tran.getAmount(i) Next i Set tran = Nothing UpdateFormState 'display and allow editing Me.Show vbModal If FormExit = vbOK Then Set tran = frmMain.BookServer.CreateTransaction tran.setComment txtComment.text If IsDate(txtDate.text) ...
Read now
Unlock full access