combobox, sorting DESC

W

Wim

Hi,

I have a combobox; its rowsource is determined by another
one (StudentCbo). Everything works fine, but I'd liked to
have it sorted descending, which I don't seem to manage.

The VBcode in the AfterUpdate event of the "determining"
combobox :

Me.CourseCbo.RowSource = "select [StudentId], [CourseId],
[InscriptionId] from [Courses] where [StudentId] = " &
lngKey

where lngKey is the value of the StudentCbo.

Now I can see the courses in the order of the
inscriptions, so oldest ones first. But I want to see the
latest courses first.

I had an snippet of code like :

Me.CourseCbo.RowSource = "select [StudentId], [CourseId],
[InscriptionId] from [Courses] where [StudentId] = " &
lngKey & " sort by CourseId DESC"

but that doesn't work. Anyone a hint ?

Thanks,

Wim
 
M

Marshall Barton

Wim said:
I have a combobox; its rowsource is determined by another
one (StudentCbo). Everything works fine, but I'd liked to
have it sorted descending, which I don't seem to manage. []
I had an snippet of code like :

Me.CourseCbo.RowSource = "select [StudentId], [CourseId],
[InscriptionId] from [Courses] where [StudentId] = " &
lngKey & " sort by CourseId DESC"

but that doesn't work. Anyone a hint ?


Hint: it's Order By
 
W

Wim

Marsh,

Thanks for the hint, I'll give it a try, though I think I
originally wrote it like that.

W
-----Original Message-----
Wim said:
I have a combobox; its rowsource is determined by another
one (StudentCbo). Everything works fine, but I'd liked to
have it sorted descending, which I don't seem to manage. []
I had an snippet of code like :

Me.CourseCbo.RowSource = "select [StudentId], [CourseId],
[InscriptionId] from [Courses] where [StudentId] = " &
lngKey & " sort by CourseId DESC"

but that doesn't work. Anyone a hint ?


Hint: it's Order By
 
W

Wim

Marsh,

You were right. Problem solved. Thank you !

Wim
-----Original Message-----
Wim said:
I have a combobox; its rowsource is determined by another
one (StudentCbo). Everything works fine, but I'd liked to
have it sorted descending, which I don't seem to manage. []
I had an snippet of code like :

Me.CourseCbo.RowSource = "select [StudentId], [CourseId],
[InscriptionId] from [Courses] where [StudentId] = " &
lngKey & " sort by CourseId DESC"

but that doesn't work. Anyone a hint ?


Hint: it's Order By
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top