combo sort order list

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i have a form with various fields on from tableX
want combo to choose field sort order. go combo fine, set to field list. i
tried using :
me.orderby = cmbsortorder.value
then setting orderbyon to true. however the value of cmbsortorder needs to
be in "" i believe...even tried adding " via chr$(34)..if this makes any
sense..pls assist.
cheers
david
 
well, i just tested it (having never done it before). i put the following
code in my unbound combo box control's AfterUpdate event, as

Me.OrderBy = Me.ComboBoxName
Me.OrderByOn = True

worked fine for me, providing an ascending sort on the field i chose from
the droplist. what event are you running the code from, and from what
control?

hth
 
This code works for me. I added the [ ] since your field names might include
spaces. You would not want to add quotes.

Private Sub cmbSortOrder_AfterUpdate()
Me.OrderBy = "[" & Me.cmbSortOrder & "]"
Me.OrderByOn = True
End Sub
 
finally worked out my stupidity..
some of the fields are themselves lookups, hence i was trying to sort on the
textual ID rather than the index of the corresponding table. ie in my primary
table fieldx held 51 which textually related to say "Mobile Phone". i was
sorting on the number 51 rather than the textual Mobile Phone, hence the sort
order was sometimes correct (just happens the lookup table was in
alphabetical order) other times it was just doing what i asked and ordered in
number order.
thanks..sorry im not so good at explaining my problems..they seem clear as
mud in my head :)

Duane Hookom said:
This code works for me. I added the [ ] since your field names might include
spaces. You would not want to add quotes.

Private Sub cmbSortOrder_AfterUpdate()
Me.OrderBy = "[" & Me.cmbSortOrder & "]"
Me.OrderByOn = True
End Sub

--
Duane Hookom
MS Access MVP

David (Gingernob) said:
i have a form with various fields on from tableX
want combo to choose field sort order. go combo fine, set to field list. i
tried using :
me.orderby = cmbsortorder.value
then setting orderbyon to true. however the value of cmbsortorder needs to
be in "" i believe...even tried adding " via chr$(34)..if this makes any
sense..pls assist.
cheers
david
 
Back
Top