Results 1 to 2 of 2

Populate Combobox with Distinct data from specific access table field

Threaded View

Macdave_19 Populate Combobox with... 04-02-2010, 05:31 AM
Macdave_19 Re: Populate Combobox with... 04-02-2010, 05:53 AM
  1. #1
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Question Populate Combobox with Distinct data from specific access table field

    Hi all,

    i'm nearly there!

    i just need some tweaking, i have a userform which is populated with data from an access database.

    basically i want to select a fileds in a combox (CBFilter1) and then populate all the distinct values from that field in another (CBCriteria1).

    here is what i have to far:

    Private Sub CBFilter1_Change()
    Dim Octrl As Control
    
    'Clear Existing Data
    Me.LBColumns.Clear
    
    'Add New Fields
    TableName = Me.CBTables.Value
    myDB = Me.TxtFilepath.Value & Me.CBDatabases.Value
       
        Set db = OpenDatabase(myDB)
        Set rs = db.OpenRecordset("SELECT DISTINCT(" & CBFilter1 & ") FROM " & TableName _
                               & ";", dbReadOnly)  ' filter records
        ' write field names into listbox
        For intColIndex = 0 To rs.RecordCount - 1
            CBCriteria1.AddItem rs.Fields(intColIndex).Value
        Next
    End Sub
    i reckon it's something to do with the bit at the bottom where it's putting in the rs.fields etc i assume it should be row related as this is wher the records will be?

    any help is really apprectiated

    thanks
    Last edited by Macdave_19; 04-02-2010 at 05:54 AM.
    Mr MaGoo
    Magoo.Inc MMVII

    If i've helped please add to my Rep by Clicking on the Blue Scales in the top right hand corner of the post

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1