Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access: Sum of Column

Status
Not open for further replies.

noiseaholic22

Technical User
Nov 5, 2009
1
US
Hello,

I'm relatively new to Access and only know what I've learned from other access users, but I would like to calculate the sum of a column in a listbox and have it pop up in a text box.

I came across this answer to my question:
-------------------------------------------------
Private Sub List7_DblClick(Cancel As Integer)
Dim listrs As Integer
Dim listsum As Integer
listrs = Me![List7].ListCount
x = 1
Do
listsum = listsum + (Me![List7].Column(6, x))
x = x + 1
Loop Until x = listrs
Me![Text9].Value = listsum
End Sub

This is with column headers. If no column headers, take out x = 1.
---------------------------------------------------

But for some odd reason it won't calculate any amounts that are not whole numbers
(.5, 1.25, etc...)
Does anyone know why or how to fix this?

Thanks!
 

But for some odd reason it won't calculate any amounts that are not whole numbers[/quote
Code:
Dim listrs As [red][b]Integer[/b][/red]
Dim listsum As [red][b]Integer[/b][/red]
change you declaration to Single

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top