Matt Greatorex
Registered User.
- Local time
- Today, 16:07
- Joined
- Jun 22, 2005
- Messages
- 1,019
I'm using the following code to find the names of the various columns in an Access table and displaying those names in a listbox. It may not look like much but, slow as I am, it took me a while to figure out .
Dim li_Count As Integer
Dim li_Max As Integer
Dim str_Source As String
li_Max = CurrentDb.TableDefs("NBReferral").Fields.Count
li_Count = 1
Do While li_Count < li_Max
str_Source = str_Source & "; " & CurrentDb.TableDefs("NBreferral").Fields(li_Count).NAME
li_Count = li_Count + 1
Loop
If Left(str_Source, 2) = "; " Then
str_Source = Right(str_Source, Len(str_Source) - 2)
End If
Me![List5].RowSourceType = "Value List"
Me![List5].RowSource = str_Source
Me![List5].Requery
This works fine but I'd ideally like to find a way to display the results in alphabetical order, as opposed to just the way in which happen to fall within the table's structure.
Given that the values are currently all part of one string, sorting is proving a bit tricky. Does anyone have any idea if there is another way to obtain the column names which would allow for the sorting I need?
Dim li_Count As Integer
Dim li_Max As Integer
Dim str_Source As String
li_Max = CurrentDb.TableDefs("NBReferral").Fields.Count
li_Count = 1
Do While li_Count < li_Max
str_Source = str_Source & "; " & CurrentDb.TableDefs("NBreferral").Fields(li_Count).NAME
li_Count = li_Count + 1
Loop
If Left(str_Source, 2) = "; " Then
str_Source = Right(str_Source, Len(str_Source) - 2)
End If
Me![List5].RowSourceType = "Value List"
Me![List5].RowSource = str_Source
Me![List5].Requery
This works fine but I'd ideally like to find a way to display the results in alphabetical order, as opposed to just the way in which happen to fall within the table's structure.
Given that the values are currently all part of one string, sorting is proving a bit tricky. Does anyone have any idea if there is another way to obtain the column names which would allow for the sorting I need?