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:
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?![]()
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
any help is really apprectiated
thanks
Bookmarks