Hi everyone there,
I am coding the cmd button to void the entry with its related transactions in tbltransactions, below is the code.
There is error in last two lines of code, also please mention the procedure is right?
I am coding the cmd button to void the entry with its related transactions in tbltransactions, below is the code.
Code:
Private Sub cmdVoidEntry_Click()
Dim VBAnsw As String
If Me.cboEntryNo > 0 Then
'If combo box is not empty then
VBAnsw = MsgBox("Do you really want to VOID the Entry?" & vbCrLf & vbCrLf _
& "This changes will be Non-Reversible !!!", vbYesNo, "Warning")
'If user's answer is Yes then update the void check box and make debit and credit values zero or null
'for related transactions in tbltransactions where Entry no is equal to cboEntryNo
If VBAnsw = vbYes Then
Dim TransactionID As Integer
Dim Debit As Integer
Dim Credit As Integer
TransactionID = DLookup("[EntryNo]", "tblTransactions", "[EntryNo]=" & Me.cboEntryNo & "")
Debit = DLookup("[CurDebit]", "tblTransactions", "[EntryNo]=" & Me.cboEntryNo & "")
Credit = DLookup("[CurCredit]", "tblTransactions", "[EntryNo]=" & Me.cboEntryNo & "")
CurrentDb.Execute "UPDATE tblTransactions Set Void = True WHERE cboEntryNo = " & TransactionID And Debit.Value = Null And Credit.Value = Null
'Here need code to add text to related transactions memo field to "VOID" in the begining of memo line.
'If there is already text in memo field if not then this will be the first sentance "VOID".
CurrentDb.Execute "UPDATE tbltransactions Set Memo = ([Memo]& "VOID" WHERE cboEntryNo = " & TransactionID
Else
Me.Undo
End If
End If
End Sub
There is error in last two lines of code, also please mention the procedure is right?