MikeT1941
Member
- Local time
- Today, 22:25
- Joined
- Nov 18, 2020
- Messages
- 47
Good evening all
This must be very basic, but I am still no better than I ever was at VBA but would like to crack this one with some help.
The purpose is to record a payment into the bank as a "Client Deposit" and then use that data to create two ledger entries.
The first one deducts the amount from the Client Deposit(40050000) account and the second adds the same amount to the Rental income account (40200000)
Both are dated 42 days before the start of the holiday rental, when the deposit become non-refundable. So there are a total of three ledger entries of which two will be excluded from reconciliation in due course.
Should I set the variables as global and use a separate subroutine?
I hope the error/s will be obvious from the code, but can supply more if required.
Any assistance appreciated
Mike
This must be very basic, but I am still no better than I ever was at VBA but would like to crack this one with some help.
The purpose is to record a payment into the bank as a "Client Deposit" and then use that data to create two ledger entries.
The first one deducts the amount from the Client Deposit(40050000) account and the second adds the same amount to the Rental income account (40200000)
Both are dated 42 days before the start of the holiday rental, when the deposit become non-refundable. So there are a total of three ledger entries of which two will be excluded from reconciliation in due course.
Should I set the variables as global and use a separate subroutine?
I hope the error/s will be obvious from the code, but can supply more if required.
Any assistance appreciated
Mike
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim NewAddDate, NewDate As Date
Dim DoICopyRecord As Variant
Dim tt1, tt2, tt3, tt4, tt5, tt6, tt7, tt8, tt9, tt10, tt11, tt12 As Variant
Dim rstbanksubformquery As Recordset
Set rstbankentries = CurrentDb.OpenRecordset(name:="banksubformquery", Type:=RecordsetTypeEnum.dbOpenDynaset)
newBankOtherCategory = 10100000
On Error GoTo Err_Click
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
If NewBankCategory = 40050000 And (Me.NewRecord) Then
Debug.Print BankID
tt2 = Me.BankDate
tt3 = Me.BankMemo & " Ledger Entry only"
tt4 = Me.BankTransaction
tt5 = Me.CofANewCode
tt6 = Me.BankMethod
tt7 = Me.BankBookingID
tt8 = Me.BankReceivedFrom
tt9 = Me.CofA_AccountID
tt10 = Me.bankReconciledFlag
tt11 = 40050000
tt12 = 10100000 'normally 10100000 current account
NewAddDate = DateAdd("d", [Text32], -42)
NewDate = Me.BankDate 'saves date for pasting to record in BankEntries
End If
With rstbankentries
.AddNew
![BankDate] = tt2
![BankMemo] = tt3
![BankTransaction] = -tt4
![CofANewCode] = tt5
![BankMethod] = tt6
![BankBookingID] = tt7
![BankReceivedFrom] = tt8
![CofA_AccountID] = tt9
![bankReconciledFlag] = tt10
![NewBankCategory] = 40050000
![newBankOtherCategory] = tt12
.Update
End With
Requery
'
' With rstbankentries
' .AddNew
'![BankDate] = tt2
'![BankMemo] = tt3
'![BankTransaction] = tt4
'![CofANewCode] = tt5
'![BankMethod] = tt6
'![BankBookingID] = tt7
'![BankReceivedFrom] = tt8
'![CofA_AccountID] = tt9
'![bankReconciledFlag] = tt10
'![NewBankCategory] = 40200000
'![newBankOtherCategory] = tt12
' .Update
' End With
'
' Requery
Exit_Click:
Exit Sub
Err_Click:
MsgBox Err.Description
Resume Exit_Click
End Sub