Sub Class_Globals
Private AcntCmb As ComboBox
Private AcntList As List
End Sub
Public Sub Initialize(Parent As Form)
AcntList.Initialize
' Loads Acnt table int AcntCmb
LoadAcntCmb
End Sub
' ExecuteMemoryTable loads into AcntList
' AcntCmb is loaded with 'Name' cols(1)
' First entry in AcntCmb is selected
' The AcntCmb_SelectedIndexChanged event is then fired
Sub LoadAcntCmb
Dim cols() As String
Dim Qry1 As String
Qry1 = "SELECT AId, Name, AvgDiv, SRate, Target, TotTarg FROM Acnt"
AcntList.Initialize
AcntList = DBUtils.ExecuteMemoryTable(DM.SQL1, Qry1, Null, 0)
If AcntList.Size > 0 Then
For i = 0 To AcntList.Size-1
cols = AcntList.Get(i)
AcntCmb.Items.Add(cols(1))
Next
' selects first entry in combobox
AcntCmb.SelectedIndex = 0
End If
End Sub
' Gets AId (PRIMARY KEY) from selected Account
' Use AcntCmb Index to get AId from AcntList
' Get any data from AcntList needed
Sub AcntCmb_SelectedIndexChanged(Index As Int, Value As Object)
Dim Cols() As String
If Index = -1 Then Return
Cols = AcntList.Get(Index)
AId = Cols(0)
TotalTarget = Cols(5)
AcAvgDiivLbl.Text = $"$${Cols(2)}"$
AcSRateLbl.Text = $"${Cols(3)}%"$
TotTargLbl.Text = $"${Cols(5)}"$
OrgTarget = Cols(4)
End Sub