PSUIVERSON
Technical User
I have an application I wrote that ties into a very large database. Depending on the account number it retrieves the detail behind a summarized number. So maybe the number is $100,000 for cash. You click on detail and it goes to the ACCESS database and returns all the detail that makes up that $100,000. I wrote a control array to handle this and outputted it to labels based on the number it returned. The problem is that some of the accounts have an inordinate amount of detail that needs to be placed in a scroll down box. It runs right off the page!! I know this is probably simple as I am a finance guy who is pretty good with VBA and VB but not a programmer by any means. Someone tell me how to capture this data in a scrolling format on the form? (Note: I played with the scrollbar control but can't figure it out ALSO - If you think I am doing something wrong and could do it better please let me know) Thanks in advance!!!
MY CODE:
Private Sub Form_Load()
Dim areaVal, fundVal, orgnVal, acctDesc, acctNum As String
Dim curDate As String
Dim adoConnection As ADODB.Connection
Dim rst As ADODB.Recordset
Dim connectString As String
' Create a new connection
Set adoConnection = New ADODB.Connection
' Creat a new Recordset
Set rst = New ADODB.Recordset
' Build connection string
connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\SOM Files\FINSYS WORK\SOMM_ConversionProcess.mdb"
adoConnection.Open connectString
' Get account Description
rst.Open "Sponsprj", adoConnection
areaVal = frmFINSYS.txtAREA
fundVal = frmFINSYS.txtFUND
orgnVal = frmFINSYS.txtORGN
acctDesc = frmFINSYS.lblDesc
acctNum = frmFINSYS.lblAccount
curDate = "As of " & rst!Date
rst.Close
' Load Detail
lblAccount.Caption = acctNum
lblDesc.Caption = acctDesc
' lblDate.Caption = curDate
' Open Up FINREC for Detail
rst.Open "FINREC", adoConnection
Dim suffixVal(0 To 50) As String
Dim suffixDescVal(0 To 50) As String
Dim fiscytdVal(0 To 50) As String
Dim enctdVal(0 To 50) As String
Dim budytdVal(0 To 50) As String
Dim count As Integer
i = 0
count = 0
rst.MoveFirst
Do While Not rst.EOF
If rst!FUND = fundVal And rst!AREA = areaVal And rst!ORGN = orgnVal Then
suffixVal(i) = rst!suffix
suffixDescVal(i) = rst!suffDesc
fiscytdVal(i) = FormatCurrency(rst!fiscYTD)
enctdVal(i) = FormatCurrency(rst!encTD)
budytdVal(i) = FormatCurrency(rst!CURRBUD)
i = i + 1
End If
rst.MoveNext
Loop
count = i
lblSuffix(0).Caption = suffixVal(0)
lblSuffDesc(0).Caption = suffixDescVal(0)
lblYTD(0).Caption = fiscytdVal(0)
lblENC(0).Caption = enctdVal(0)
lblCB(0).Caption = budytdVal(0)
For i = 1 To count
Load lblSuffix(i)
Load lblSuffDesc(i)
Load lblYTD(i)
Load lblENC(i)
Load lblCB(i)
lblSuffix(i).Top = lblSuffix(i - 1).Top + lblSuffix(0).Height
lblSuffDesc(i).Top = lblSuffDesc(i - 1).Top + lblSuffDesc(0).Height
lblYTD(i).Top = lblYTD(i - 1).Top + lblYTD(0).Height
lblENC(i).Top = lblENC(i - 1).Top + lblENC(0).Height
lblCB(i).Top = lblCB(i - 1).Top + lblCB(0).Height
lblSuffix(i).Caption = suffixVal(i)
lblSuffDesc(i).Caption = suffixDescVal(i)
lblYTD(i).Caption = fiscytdVal(i)
lblENC(i).Caption = enctdVal(i)
lblCB(i).Caption = budytdVal(i)
lblSuffix(i).Visible = True
lblSuffDesc(i).Visible = True
lblYTD(i).Visible = True
lblENC(i).Visible = True
lblCB(i).Visible = True
Next i
Set rst = Nothing
End Sub
MY CODE:
Private Sub Form_Load()
Dim areaVal, fundVal, orgnVal, acctDesc, acctNum As String
Dim curDate As String
Dim adoConnection As ADODB.Connection
Dim rst As ADODB.Recordset
Dim connectString As String
' Create a new connection
Set adoConnection = New ADODB.Connection
' Creat a new Recordset
Set rst = New ADODB.Recordset
' Build connection string
connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\SOM Files\FINSYS WORK\SOMM_ConversionProcess.mdb"
adoConnection.Open connectString
' Get account Description
rst.Open "Sponsprj", adoConnection
areaVal = frmFINSYS.txtAREA
fundVal = frmFINSYS.txtFUND
orgnVal = frmFINSYS.txtORGN
acctDesc = frmFINSYS.lblDesc
acctNum = frmFINSYS.lblAccount
curDate = "As of " & rst!Date
rst.Close
' Load Detail
lblAccount.Caption = acctNum
lblDesc.Caption = acctDesc
' lblDate.Caption = curDate
' Open Up FINREC for Detail
rst.Open "FINREC", adoConnection
Dim suffixVal(0 To 50) As String
Dim suffixDescVal(0 To 50) As String
Dim fiscytdVal(0 To 50) As String
Dim enctdVal(0 To 50) As String
Dim budytdVal(0 To 50) As String
Dim count As Integer
i = 0
count = 0
rst.MoveFirst
Do While Not rst.EOF
If rst!FUND = fundVal And rst!AREA = areaVal And rst!ORGN = orgnVal Then
suffixVal(i) = rst!suffix
suffixDescVal(i) = rst!suffDesc
fiscytdVal(i) = FormatCurrency(rst!fiscYTD)
enctdVal(i) = FormatCurrency(rst!encTD)
budytdVal(i) = FormatCurrency(rst!CURRBUD)
i = i + 1
End If
rst.MoveNext
Loop
count = i
lblSuffix(0).Caption = suffixVal(0)
lblSuffDesc(0).Caption = suffixDescVal(0)
lblYTD(0).Caption = fiscytdVal(0)
lblENC(0).Caption = enctdVal(0)
lblCB(0).Caption = budytdVal(0)
For i = 1 To count
Load lblSuffix(i)
Load lblSuffDesc(i)
Load lblYTD(i)
Load lblENC(i)
Load lblCB(i)
lblSuffix(i).Top = lblSuffix(i - 1).Top + lblSuffix(0).Height
lblSuffDesc(i).Top = lblSuffDesc(i - 1).Top + lblSuffDesc(0).Height
lblYTD(i).Top = lblYTD(i - 1).Top + lblYTD(0).Height
lblENC(i).Top = lblENC(i - 1).Top + lblENC(0).Height
lblCB(i).Top = lblCB(i - 1).Top + lblCB(0).Height
lblSuffix(i).Caption = suffixVal(i)
lblSuffDesc(i).Caption = suffixDescVal(i)
lblYTD(i).Caption = fiscytdVal(i)
lblENC(i).Caption = enctdVal(i)
lblCB(i).Caption = budytdVal(i)
lblSuffix(i).Visible = True
lblSuffDesc(i).Visible = True
lblYTD(i).Visible = True
lblENC(i).Visible = True
lblCB(i).Visible = True
Next i
Set rst = Nothing
End Sub