PC Review


Reply
Thread Tools Rate Thread

Listbox Order by not sequntial

 
 
Billy B
Guest
Posts: n/a
 
      21st Apr 2010
I have the following c ode in the OnLoad event of a form which generates the
numbers I need in an unbound control. The problem is the sequence order
being displayed (10, 11, 14, 159, 21, 211, 30). Is there any way I do to
correct the problem?

Me.lstCode.RowSource = "SELECT DISTINCT Code FROM [PO Master] WHERE Code <>
'""' ORDER BY Code ASC;"
 
Reply With Quote
 
 
 
 
Ken Snell
Guest
Posts: n/a
 
      21st Apr 2010
ACCESS is seeing your numbers as text, so it's sorting using text rules and
not number rules. Try this:

Me.lstCode.RowSource = "SELECT DISTINCT Code FROM [PO Master] WHERE Code <>
'""' ORDER BY Val(Code) ASC;"

--

Ken Snell
http://www.accessmvp.com/KDSnell/



"Billy B" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have the following c ode in the OnLoad event of a form which generates
>the
> numbers I need in an unbound control. The problem is the sequence order
> being displayed (10, 11, 14, 159, 21, 211, 30). Is there any way I do to
> correct the problem?
>
> Me.lstCode.RowSource = "SELECT DISTINCT Code FROM [PO Master] WHERE Code
> <>
> '""' ORDER BY Code ASC;"



 
Reply With Quote
 
 
 
 
Billy B
Guest
Posts: n/a
 
      21st Apr 2010
Thanks Ken. When I tried this but no results are showing in the listbox. I
copied your code and pasted it in the ON Load event but I'm not getting
anything.

"Ken Snell" wrote:

> ACCESS is seeing your numbers as text, so it's sorting using text rules and
> not number rules. Try this:
>
> Me.lstCode.RowSource = "SELECT DISTINCT Code FROM [PO Master] WHERE Code <>
> '""' ORDER BY Val(Code) ASC;"
>
> --
>
> Ken Snell
> http://www.accessmvp.com/KDSnell/
>
>
>
> "Billy B" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I have the following c ode in the OnLoad event of a form which generates
> >the
> > numbers I need in an unbound control. The problem is the sequence order
> > being displayed (10, 11, 14, 159, 21, 211, 30). Is there any way I do to
> > correct the problem?
> >
> > Me.lstCode.RowSource = "SELECT DISTINCT Code FROM [PO Master] WHERE Code
> > <>
> > '""' ORDER BY Code ASC;"

>
>
> .
>

 
Reply With Quote
 
Ken Snell
Guest
Posts: n/a
 
      21st Apr 2010
Probably a linewrapping problem? All I did was add the Val function as a
wrapper to your Code field in the ORDER BY clause. Go back to what you had
originally, then add the Val function as I did to your code.

--

Ken Snell
http://www.accessmvp.com/KDSnell/



"Billy B" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Ken. When I tried this but no results are showing in the listbox. I
> copied your code and pasted it in the ON Load event but I'm not getting
> anything.
>
> "Ken Snell" wrote:
>
>> ACCESS is seeing your numbers as text, so it's sorting using text rules
>> and
>> not number rules. Try this:
>>
>> Me.lstCode.RowSource = "SELECT DISTINCT Code FROM [PO Master] WHERE Code
>> <>
>> '""' ORDER BY Val(Code) ASC;"
>>
>> --
>>
>> Ken Snell
>> http://www.accessmvp.com/KDSnell/
>>
>>
>>
>> "Billy B" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> >I have the following c ode in the OnLoad event of a form which generates
>> >the
>> > numbers I need in an unbound control. The problem is the sequence order
>> > being displayed (10, 11, 14, 159, 21, 211, 30). Is there any way I do
>> > to
>> > correct the problem?
>> >
>> > Me.lstCode.RowSource = "SELECT DISTINCT Code FROM [PO Master] WHERE
>> > Code
>> > <>
>> > '""' ORDER BY Code ASC;"

>>
>>
>> .
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sequntial Number in Excel DuncanL Microsoft Excel Programming 0 15th Aug 2007 03:21 PM
Listbox item added with client scripts not submitting with ASP:Listbox Simon Prince Microsoft ASP .NET 2 19th Oct 2004 05:11 PM
Graph reverse order changes series order but not legend order biddlea Microsoft Excel Misc 0 13th Aug 2004 12:48 PM
Moving listbox item from listbox to listbox Kevin Quigley Microsoft Dot NET 2 2nd Jun 2004 11:34 AM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Microsoft Excel Programming 0 22nd Oct 2003 12:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:35 PM.