Option Explicit
Dim objCurrLi As ListItem
Dim InsCoId As String
Dim SumColumb As Double
Private Sub cboInsCo_GotFocus()
ListView1.ListItems.Clear 'Clear existing ListView
SumColumb = "0.00"
lblBal.Caption = SumColumb
lblBal.Caption = "" 'Clear Balance Display
End Sub
Private Sub cmdLstAcc_Click()
Dim TotalCharges As Double
Dim abc As Integer
InsCoId = lblInsCo.Caption
ListView1.ListItems.Clear 'Clear existing ListView
If cboInsCo.Text = "" Then
MsgBox "No Insurance Company has been selected.", vbExclamation, "Data Entry Error"
GoTo abc 'Avoid opening Recordset if no Insurance Company is selected, jump to abc
Else
End If
'Set up and open Access connection and recordset
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider =Microsoft.Jet.OLEDB.4.0;" & "Data Source = C:\SKM_ICE Database\SKM_ICE DBase.mdb"
cn.Open
Set rsAccounts = New ADODB.Recordset
rsAccounts.Open "SELECT OurRef, YourRef, Date, insured2, totalcharges" _
& " From tbl_master" _
& " Where InsCoId = " & InsCoId & " And PaymentReceived = 'NO'", cn
TotalCharges = rsAccounts!TotalCharges
'Populate ListView
Do While Not rsAccounts.EOF
Set objCurrLi = ListView1.ListItems.Add(, , rsAccounts!ourRef & "") 'Our Ref
objCurrLi.SubItems(1) = rsAccounts!YourRef & "" 'Your Ref
objCurrLi.SubItems(2) = rsAccounts!Date & "" 'Date
objCurrLi.SubItems(3) = rsAccounts!Insured2 & "" 'Insured2
objCurrLi.SubItems(4) = rsAccounts!TotalCharges & "" 'Total charges
SumColumb = SumColumb + rsAccounts!TotalCharges
rsAccounts.MoveNext
Loop
'Close Access connection and recordset
rsAccounts.Close
cn.Close
Set rsAccounts = Nothing
Set cn = Nothing
lblBal.Caption = SumColumb
lblBal.Caption = Format(lblBal, "####0.00")
abc: ' Jumps to here from GoTo statement if cboInsCo.Text = ""
End Sub
Private Sub cmdClose_Click() 'Return to Report screen
ListView1.ListItems.Clear 'Clear existing ListView
frmOtstngAcc.Hide
Unload Me
End Sub