Results 1 to 4 of 4
  1. #1
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    1,009

    PickList Custom Class

    In a post on some board I can no longer find, someone asked a question about picklists and how to move the items between the lists.


    Having just worked on something utilizing a Scripting Dictionary object, I had a thought about implimenting a dictionary object in a custom class
    with a pick list. It's extremely easy to add and remove values from dictionaries so I thought I'd give it a go.

    I'd be interested in hearing any ways to add to or improve its functionality.

    The 2 lines of code in your form module are shown below.
    The only arguments passed to the Class are the listbox objects.

    Code:
    Option Compare Database
    Option Explicit
    
    
    Dim clsPL As New clsPickList    'instaniate the class
    
    
    Private Sub Form_Load()
    
    
        clsPL.InitMyClass Me.List4, Me.List6  'initiate the instance
    
    
    End Sub
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    15,885
    Moke123,

    There used to be a great video on displaying and moving things from 1 list to another. That was on the DataPig website which has been taken down over the last couple of years.

    Thanks for posting your code.

  3. #3
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    1,009
    I made a few changes to my first version above.
    I added comments to the class module for easier understanding and a little code modification.

    There is now no need to set the column count or column widths of the rightside (selected items) listbox and
    no rowsource is required. Just drop a blank listbox on your form and size it as needed. The settings are copied over
    from the leftside (selections) listbox to the rightside listbox.

    I originally thought that applying a where clause to the leftside listbox's rowsource would cause a problem with the
    procedure that modifies the rowsource but that doesn't seem to be the case so far. It doesn't seem to matter as long as the
    rowsource is based on a table with the primary key field in the first column. I'll need further testing to see just how complicated
    a where clause can be.

    FYI - Cross posted here https://www.access-programmers.co.uk...-class.316665/
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  4. #4
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    1,009
    An Updated version of the demo.

    Added a function to return the value of the selected items and the ability to test the different optional arguments.
    Click image for larger version. 

Name:	DemoLB.jpg 
Views:	17 
Size:	49.5 KB 
ID:	44514

    The function has 4 optional arguments.
    intColumn to select the column to return. Defaults to column(0)
    delimiter to delimit the return values. Defaults is nothing. Can use to delimit dates with octothorpes(#) or strings with quotes(")
    separator to chose the separating character. Defaults to comma(,). Can use Pipes(|) or any other string.
    autoreset as boolean. To determine whether to clear the selected list when function is run.

    I also added another table and the ability to switch the rowsource of the listboxes just to demonstrate date datatypes
    and delimiting them with octothorpes.
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 11-06-2020, 09:57 AM
  2. Replies: 5
    Last Post: 04-29-2019, 03:16 AM
  3. Custom class not working on Enter key
    By Ruegen in forum Programming
    Replies: 1
    Last Post: 10-29-2014, 10:44 PM
  4. Replies: 2
    Last Post: 05-27-2014, 11:32 AM
  5. Implementing Custom Class Objects-Where should they go?
    By Monterey_Manzer in forum Database Design
    Replies: 5
    Last Post: 04-07-2014, 12:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums