DD's Stats

Total Members: 157
Latest: irsmalik
New This Month: 7
New This Week: 3
New Today: 0
Total Posts: 876
Total Topics: 444
Most Online Today: 3
Most Online Ever: 52
(May 02, 2020, 05:24:19 pm)
Users Online
Members: 0
Guests: 1
Total: 1

Recommended Posts

DD Approved Members group Added by DD Admin
05-06-2020, 12:48:35

Posting Additions or alterations rules by DD Admin
27-02-2020, 10:33:01

A Trip Down Memory Lane by DD Admin
24-08-2019, 14:17:16

Todays Birthdays

DD's Top Posters

DD Admin
Posts: 910
Posts: 69
Posts: 12
Posts: 8
Posts: 8
Posts: 5
Posts: 5

Author Topic: Looping through Listbox Selected Items list  (Read 8 times)

0 Members and 0 Guests are viewing this topic.

Offline DD Admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 910
  • Karma: +5/-0
  • Gender: Male
  • Db Dreams Owner
  • Location: Margate, UK
  • Referrals: 16
Looping through Listbox Selected Items list
« on: April 26, 2020, 09:53:11 pm »
Platform: VBA
Object: ListBox

Code: [Select]
'Description: Loop through a list box
'Called By:
'Returns: N/a
'Author: Michael Javes, Database Dreams
'Editor(s) :
'Date Created: N/A
'Rev. History:
'Requirements: lst_emps Name given to list
Dim m_Db As Database
Dim Emp As DAO.Recordset
Dim VarNum As Variant
On Error GoTo HandleErr
Set m_Db = CurrentDb()

'Updatabale recordset Adding records only
Set Emp = m_Db.OpenRecordset("SELECT * FROM YourTable", dbOpenDynaset, dbAppendOnly)
If lst_emps.ItemsSelected.Count <> 0 Then
        For Each VarNum In lst_emps.ItemsSelected
        With Emp
        'Do Something
       End With
End If
'Cean Up
Set Emp = Nothing
Set m_Db = Nothing
'Close this forum
    Exit Sub
    Select Case Err.Number
        Case Else
            MsgBox Err.Number & vbCrLf & Err.Description
            Resume HandleExit
    End Select

Share on Facebook Share on Twitter


Related Topics

  Subject / Started by Replies Last post
0 Replies
Last post March 20, 2020, 10:45:51 pm
by DD Admin
0 Replies
Last post April 26, 2020, 09:49:26 pm
by DD Admin
0 Replies
Last post July 09, 2020, 03:07:00 pm
by DD Admin
0 Replies
Last post July 09, 2020, 03:14:59 pm
by DD Admin
0 Replies
Last post December 25, 2020, 06:24:08 pm
by DD Admin

DD's Social Media

DD's Programs

Development Schedule

DD's Freeware


DJ 2020

Chart Tracker Elite

Works Manager

Contact Manager

Simple Home Accounts

Book Library

Picture Library

Project Manager (accde)

Developer Tools

Project Manager (accdb)

Style Manager

Code Library

Open Code Templates

Master Template

Task Management

Charitable Contributions

Bug Tracker Template

Time And Billing Template

Real Estate Template

Household Inventory V1

Open Code Examples

DD's Northwind V1

Employee Example V5

Grid Demo Example V1

Employee Example V4

Small Examples

Recent Topics

Apollo Project Status by DD Admin
January 15, 2021, 11:00:15 am

Apollo Manual: Main Music Player by DD Admin
January 13, 2021, 10:21:36 am

UK Singles/Albums Charts 01 Jan 2021 to 07 Jan 2021 Analysis by borobutch
January 11, 2021, 09:27:29 pm

Please welcome irsmalik to DD by DD Admin
January 11, 2021, 09:34:58 am

Please welcome FamiliaRoca to DD by DD Admin
January 11, 2021, 07:49:40 am

Please welcome Gasman to DD by DD Admin
January 10, 2021, 02:01:23 pm

Please welcome ferrancc to DD by DD Admin
January 09, 2021, 06:21:49 pm

Database Dreams is not affiliated with Microsoft