ListBox in Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hekmatullah
    New Member
    • Aug 2008
    • 2

    ListBox in Access

    Dear All,
    I have three ListBoxes in Ms. Access form, 1st one is Getting Earned Leave from Database, 2nd one is getting Used Leave from Database, 3 one is making Balance and showing remained Leave, but each Listbox has three columns as AnnualLeave, SickLeave, CompTime.
    Please teach me that how to calculate each column's row?
    thanks
    Hekmatullah
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    I'm not sure if I interpret your request exactly, but the following code will list each Row Number, and each of the 3 Column Values in a List Box named List0. The Row Source of the List Box is taken from values within the Employees Table of the Northwind Database.
    Code:
    Dim intNumberOfEntries As Integer
    Dim intCounter As Integer
    
    intNumberOfEntries = Me![List0].ListCount
    
    If intNumberOfEntries > 0 Then
      With Me![List0]
        For intCounter = 0 To intNumberOfEntries - 1
                               
          Debug.Print "Row: " & intCounter + 1 & " | " & .Column(0, intCounter) & " | " & .Column(1, intCounter) & _
                            " | " & .Column(2, intCounter)      
        Next
      End With
    End If
    OUTPUT:
    Row: 1 | Sales Representative | Nancy | Davolio
    Row: 2 | Vice President, Sales | Andrew | Fuller
    Row: 3 | Sales Representative | Janet | Leverling
    Row: 4 | Sales Representative | Margaret | Peacock
    Row: 5 | Sales Manager | Steven | Buchanan
    Row: 6 | Sales Representative | Michael | Suyama
    Row: 7 | Sales Representative | Robert | King
    Row: 8 | Inside Sales Coordinator | Laura | Callahan
    Row: 9 | Sales Representative | Anne | Dodsworth

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32661

      #3
      A common way to populate ListBoxes is with a query. I suspect this will suit your purpose. Your query needs to include all the columns required for the ListBox, so you would need a column with the correct calculation in it. Calculations are not done within the ListBox control itself.

      Does this help?

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by NeoPa
        A common way to populate ListBoxes is with a query. I suspect this will suit your purpose. Your query needs to include all the columns required for the ListBox, so you would need a column with the correct calculation in it. Calculations are not done within the ListBox control itself.

        Does this help?
        Did I miss the boat on this one by that much? (LOL).

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32661

          #5
          You & I both know that interpretation of members questions often requires large doses of intuition and (sometimes informed) guesswork.

          Sometimes you hit, and sometimes you miss :D

          Whoever knows for sure until the OP replies ;)

          Comment

          Working...