Hi everyone
I am designing a data input form. I have the code developed so far:
.........................................................................................
code:
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub OKButton_Click()
'Find the next row of the data sheet
nextrow = Worksheets("Bank Payment").Cells(Rows.Count, 1).End(xlUp).Row + 1
'Transfer data from ExpenseClassificationForm to worksheet
With Worksheets("Bank Payment")
.Cells(nextrow, 1).ClearFormats
On Error GoTo DateValidation
.Cells(nextrow, 1).Value = CDate(Me.DateText) 'CDate(Me.DateText)does the same thing as Format((Me.DateText), "dd/mm/yyyy") added below to achive the same result.
On Error GoTo 0
.Cells(nextrow, 2).Value = Me.ParticularsText
.Cells(nextrow, 3).Value = Me.ReferenceText
.Cells(nextrow, 4).Value = Format((Me.TBTotalAmount), "0.00")
End With
DateValidation:
MsgBox Prompt:="No date is entered for this transaction,Click on OK to continue or Click on Cancel to enter a date", Buttons:=vbOKCancel, Title:="Hashiru Chartered Certified Accountants"
If vbOK Then
Call UserFormReinitialization
End If
End Sub
Private Sub UserFormReinitialization()
Unload Me
ExpenseClassificationForm.Show
ExpenseClassificationForm.DateText.Value = " "
ExpenseClassificationForm.DateText.SetFocus
End Sub
Private Sub TBVATC0DE_Change()
On Error Resume Next
Me.TBvatAmount = Me.TBTotalAmount * Me.TBVATC0DE
Me.TBnetAmount = Me.TBTotalAmount - Me.TBvatAmount
End Sub
Private Sub UserForm_Initialize()
With TBVATC0DE
'Fill the VAT Code text Box
.AddItem "20%"
.AddItem "5%"
.AddItem "0%"
End With
TBVATC0DE.ListIndex = 0
End Sub
...............................................................................................
Request:
I want to develop the block of code to calculate the vat amount and the vat net amount and then show these amounts on the data input form.
With these, users of the form will only have to enter the total amount.
Vat calculation should be based on the total amount (on TBTotalAmount textbox) and the tax rate (selected on the text box TBVATCODE)
Net amount now being the difference between TBTotalAmount and TBVATCDE
...............................................................................................
Thanks in advance
I am designing a data input form. I have the code developed so far:
.........................................................................................
code:
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub OKButton_Click()
'Find the next row of the data sheet
nextrow = Worksheets("Bank Payment").Cells(Rows.Count, 1).End(xlUp).Row + 1
'Transfer data from ExpenseClassificationForm to worksheet
With Worksheets("Bank Payment")
.Cells(nextrow, 1).ClearFormats
On Error GoTo DateValidation
.Cells(nextrow, 1).Value = CDate(Me.DateText) 'CDate(Me.DateText)does the same thing as Format((Me.DateText), "dd/mm/yyyy") added below to achive the same result.
On Error GoTo 0
.Cells(nextrow, 2).Value = Me.ParticularsText
.Cells(nextrow, 3).Value = Me.ReferenceText
.Cells(nextrow, 4).Value = Format((Me.TBTotalAmount), "0.00")
End With
DateValidation:
MsgBox Prompt:="No date is entered for this transaction,Click on OK to continue or Click on Cancel to enter a date", Buttons:=vbOKCancel, Title:="Hashiru Chartered Certified Accountants"
If vbOK Then
Call UserFormReinitialization
End If
End Sub
Private Sub UserFormReinitialization()
Unload Me
ExpenseClassificationForm.Show
ExpenseClassificationForm.DateText.Value = " "
ExpenseClassificationForm.DateText.SetFocus
End Sub
Private Sub TBVATC0DE_Change()
On Error Resume Next
Me.TBvatAmount = Me.TBTotalAmount * Me.TBVATC0DE
Me.TBnetAmount = Me.TBTotalAmount - Me.TBvatAmount
End Sub
Private Sub UserForm_Initialize()
With TBVATC0DE
'Fill the VAT Code text Box
.AddItem "20%"
.AddItem "5%"
.AddItem "0%"
End With
TBVATC0DE.ListIndex = 0
End Sub
...............................................................................................
Request:
I want to develop the block of code to calculate the vat amount and the vat net amount and then show these amounts on the data input form.
With these, users of the form will only have to enter the total amount.
Vat calculation should be based on the total amount (on TBTotalAmount textbox) and the tax rate (selected on the text box TBVATCODE)
Net amount now being the difference between TBTotalAmount and TBVATCDE
...............................................................................................
Thanks in advance