ListBox Sum

  • Thread starter Balmora via AccessMonster.com
  • Start date
B

Balmora via AccessMonster.com

I have foung many threads that talk aboud that but i find them confusing. i
would like to find an easy way to sum up a column that is filtered and is
requery with a curent form event. so here is the deal.

First Table : Loans

ID, Name, Total, Percent,
Column 1 is 0, 2 is 1 and 3 is 2 all is good so far

Sec Table: Budget

..., ListBoxLoans, LoansTotal, LoansPercent1, ...,

So i was thinking that i could sum up column 2 of ListBoxLoans in LoansTotal
with the Form_Current event:

Private Sub Form_Current()
Me.ListBoxLoans.Requery
End Sub

Because a have a requery of that listbox in that event
I think i gave all the important stuff

And Second question just for the heck of it, how can i thransfer a number
from a listbox to a text box.
lets say that the listboxloans can not display more the 4 lines or record
dont know what to call it, and i want to put the number in column 3 wich is
Percent to a text box called LoansPercent1 and there would be LoansPercent2,
LoansPercent3 and LoansPercent4 how would i go about doing that? i would like
to use the Form_Current event again of corse :)

Thanks for all your help in advence :)
 
B

Balmora via AccessMonster.com

Balmora said:
I have foung many threads that talk aboud that but i find them confusing. i
would like to find an easy way to sum up a column that is filtered and is
requery with a curent form event. so here is the deal.

First Table : Loans

ID, Name, Total, Percent,
Column 1 is 0, 2 is 1 and 3 is 2 all is good so far

Sec Table: Budget

..., ListBoxLoans, LoansTotal, LoansPercent1, ...,

So i was thinking that i could sum up column 2 of ListBoxLoans in LoansTotal
with the Form_Current event:

Private Sub Form_Current()
Me.ListBoxLoans.Requery
End Sub

Because a have a requery of that listbox in that event
I think i gave all the important stuff

And Second question just for the heck of it, how can i thransfer a number
from a listbox to a text box.
lets say that the listboxloans can not display more the 4 lines or record
dont know what to call it, and i want to put the number in column 3 wich is
Percent to a text box called LoansPercent1 and there would be LoansPercent2,
LoansPercent3 and LoansPercent4 how would i go about doing that? i would like
to use the Form_Current event again of corse :)

Thanks for all your help in advence :)


So i got half of what i needed :) here is how i did it :)

Private Sub Form_Current()
Me.ListBoxLoans.Requery

Dim i As Integer
Dim lngSum As Long
For i = 0 To Me.ListBoxLoans.ListCount - 1
lngSum = lngSum + CLng(Me.ListBoxLoans.Column(2, i))
Next
Me.LoanTotal = lngSum

End Sub

I hope to have some help for my second question :(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top