XelaIrodavlas
Registered User.
- Local time
- Today, 15:17
- Joined
- Oct 26, 2012
- Messages
- 175
Hi All,
This is probably simpler than I realise but hard to explain (please bear with me). I have some code setup which sorts records of a continuous form alphabetically. The user clicks on a header label and it adds to the OrderBy property. See code below, it works fine, with one exception...
The hiccup is I have a number of ComboBox controls which are linked to foreignID fields (integer), which lookup name values from another table. The problem is when I sort by those Fields, it puts them in order of the numerical ID (ie 1, 2, 3), not the name i'm looking up.
Does anyone know a way to lookup the string that's being displayed in a combo box, and sort using those values instead of the underlying ID?
Here's an example to help illustrate the problem.
ID ¦ Name (in foreign Table)
1 ¦ Zebra
2 ¦ Alpacca
3 ¦ Moose
Currently this is sorting in order 1, 2, 3, but I want it to go 2, 3, 1... Ie alphabetically based on the lookup value. Hope that makes sense.
Here's my (simplified) code:
Any help much appreciated! ^^
This is probably simpler than I realise but hard to explain (please bear with me). I have some code setup which sorts records of a continuous form alphabetically. The user clicks on a header label and it adds to the OrderBy property. See code below, it works fine, with one exception...
The hiccup is I have a number of ComboBox controls which are linked to foreignID fields (integer), which lookup name values from another table. The problem is when I sort by those Fields, it puts them in order of the numerical ID (ie 1, 2, 3), not the name i'm looking up.
Does anyone know a way to lookup the string that's being displayed in a combo box, and sort using those values instead of the underlying ID?
Here's an example to help illustrate the problem.
ID ¦ Name (in foreign Table)
1 ¦ Zebra
2 ¦ Alpacca
3 ¦ Moose
Currently this is sorting in order 1, 2, 3, but I want it to go 2, 3, 1... Ie alphabetically based on the lookup value. Hope that makes sense.
Here's my (simplified) code:
Code:
'Add Sort Order: Animals
Dim vOldOrder As String
'Check if there's an existing OrderBy Clause:
If Len(Me.OrderBy & vbNullString) > 0 Then vOldOrder = ", " & Me.OrderBy
'Add new sort to OrderBy:
Me.OrderBy = "[AnimalID]" & vOldOrder
Me.OrderByOn = True
Any help much appreciated! ^^
Last edited: