Private Sub cboClose_Click()
Dim tblTransactionList As ListObject
Dim ws As Worksheet
Dim NwRow As ListRow
Dim linrng As Variant
Select Case cboClose.Value
Case "Save and close"
FormEventsEnabled = False
Application.ScreenUpdating = False
Application.EnableEvents = False 'Prevent the Worksheet_Change() event from being fired over-and-over
Set NwRow = Worksheets("TransactionList").ListObjects("tblTransactionList").ListRows.Add(AlwaysInsert:=True)
Select Case cboType.Value
Case "Invoice"
With NwRow.Range
.Cells(1, 1).Value = txtNo.Value
.Cells(1, 2).Value = txtUnitOwner.Value
.Cells(1, 3).Value = dtbxTransactionDate.Value
.Cells(1, 4).Value = cboType.Value
.Cells(1, 5).Value = cboAction.Value
.Cells(1, 6).Value = txtTotal.Value * -1
.Cells(1, 7).Value = txtMemo.Value
End With
Set NwRow = Nothing 'Clean up
Case "Credit memo"
With NwRow.Range
.Cells(1, 1).Value = txtNo.Value
.Cells(1, 2).Value = txtUnitOwner.Value
.Cells(1, 3).Value = dtbxTransactionDate.Value
.Cells(1, 4).Value = cboType.Value
.Cells(1, 5).Value = cboAction.Value
.Cells(1, 6).Value = txtTotal.Value
.Cells(1, 7).Value = txtMemo.Value
End With
Set NwRow = Nothing 'Clean up
Case "Check"
With NwRow.Range
.Cells(1, 1).Value = txtNo.Value
.Cells(1, 2).Value = txtUnitOwner.Value
.Cells(1, 3).Value = dtbxTransactionDate.Value
.Cells(1, 4).Value = cboType.Value
.Cells(1, 5).Value = cboAction.Value
.Cells(1, 6).Value = txtTotal.Value * -1
.Cells(1, 7).Value = txtMemo.Value
End With
Set NwRow = Nothing 'Clean up
Case "Payment"
With NwRow.Range
.Cells(1, 1).Value = txtNo.Value
.Cells(1, 2).Value = txtUnitOwner.Value
.Cells(1, 3).Value = dtbxTransactionDate.Value
.Cells(1, 4).Value = cboType.Value
.Cells(1, 5).Value = cboAction.Value
.Cells(1, 6).Value = txtTotal.Value
.Cells(1, 7).Value = txtMemo.Value
End With
Set NwRow = Nothing 'Clean up
End Select
FormEventsEnabled = True
Application.ScreenUpdating = True
Application.EnableEvents = True
UseDatePicker False, Me 'Stop Using the DatePicker
Unload Me
Case "Save and new"
FormEventsEnabled = False
Application.ScreenUpdating = False
Application.EnableEvents = False 'Prevent the Worksheet_Change() event from being fired over-and-over
Set NwRow = Worksheets("TransactionList").ListObjects("tblTransactionList").ListRows.Add(AlwaysInsert:=True)
Select Case cboType.Value
Case "Invoice"
With NwRow.Range
.Cells(1, 1).Value = txtNo.Value
.Cells(1, 2).Value = txtUnitOwner.Value
.Cells(1, 3).Value = dtbxTransactionDate.Value
.Cells(1, 4).Value = cboType.Value
.Cells(1, 5).Value = cboAction.Value
.Cells(1, 6).Value = txtTotal.Value * -1
.Cells(1, 7).Value = txtMemo.Value
End With
Set NwRow = Nothing 'Clean up
Case "Credit memo"
With NwRow.Range
.Cells(1, 1).Value = txtNo.Value
.Cells(1, 2).Value = txtUnitOwner.Value
.Cells(1, 3).Value = dtbxTransactionDate.Value
.Cells(1, 4).Value = cboType.Value
.Cells(1, 5).Value = cboAction.Value
.Cells(1, 6).Value = txtTotal.Value
.Cells(1, 7).Value = txtMemo.Value
End With
Set NwRow = Nothing 'Clean up
Case "Check"
With NwRow.Range
.Cells(1, 1).Value = txtNo.Value
.Cells(1, 2).Value = txtUnitOwner.Value
.Cells(1, 3).Value = dtbxTransactionDate.Value
.Cells(1, 4).Value = cboType.Value
.Cells(1, 5).Value = cboAction.Value
.Cells(1, 6).Value = txtTotal.Value * -1
.Cells(1, 7).Value = txtMemo.Value
End With
Set NwRow = Nothing 'Clean up
Case "Payment"
With NwRow.Range
.Cells(1, 1).Value = txtNo.Value
.Cells(1, 2).Value = txtUnitOwner.Value
.Cells(1, 3).Value = dtbxTransactionDate.Value
.Cells(1, 4).Value = cboType.Value
.Cells(1, 5).Value = cboAction.Value
.Cells(1, 6).Value = txtTotal.Value
.Cells(1, 7).Value = txtMemo.Value
End With
Set NwRow = Nothing 'Clean up
End Select
Me.txtNo = ""
Me.cboType = "Invoice"
Me.cboAction = ""
Me.txtTotal = "$0.00"
'Me.txtMemo = ""
Me.txtNo = WorksheetFunction.Max(Range("tblTransactionList[[#All],[Number]]"), Range("tblDeletedTrans[[#All],[Number]]")) + 1
End Select
End Sub
When I close with Save and new I get the following error. It does record the transaction but won't bring the form back cleared
Bookmarks