Results 1 to 2 of 2

Thread: listbox values

  1. #1
    Join Date
    Jun 2002

    Unanswered: 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)
    Me.Job_Hrs.Value = JHrs
    End Sub

  2. #2
    Join Date
    Dec 2002
    Préverenges, Switzerland
    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts