If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > listbox values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-20-02, 16:21
skate skate is offline
Registered User
 
Join Date: Jun 2002
Posts: 19
listbox values

I have a listbox with values that I want added from a certain column and the result displayed in textbox. This is my code, but it doesn't work. It keeps giving my type mismatch and I can't figure out why. The column I am adding is a double

Private Sub Hrs_Calc()
Dim i As Integer
Dim JHrs As Double
i = 0
JHrs = 0
'12 months
For i = 0 To lstResults.ListCount - 1
JHrs = JHrs + lstResults.Column(5, i)
Next
Me.Job_Hrs.Value = JHrs
End Sub
Reply With Quote
  #2 (permalink)  
Old 12-23-02, 03:50
izyrider izyrider is offline
Cavalier King Charles
 
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,731
assuming your list box is pulling its data from a table or a query, why not try a domain aggregate function:

MyAnswer = DSum("[nameOfFieldInTableOrQuery]", "nameOfTableOrQuery")

it's a lot more elegant than stepping through the list.


izy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On