PC Review


Reply
Thread Tools Rate Thread

DataView sort fails to sort on fields with comma in field names

 
 
Mone Hsieh
Guest
Posts: n/a
 
      14th May 2004
hi all

I have a dataset which has column with comma in its name.

How do I use DataView to sort it properly? The DataView.Sort always break
the line when it sees a comma. Then it complains about field name being
invalid. I've tried quoting my field name with '"' or ''' but they all fail
the same way.

any idea how to make it work?

Mone


 
Reply With Quote
 
 
 
 
Erik Frey
Guest
Posts: n/a
 
      14th May 2004
"Mone Hsieh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> hi all
>
> I have a dataset which has column with comma in its name.
>
> How do I use DataView to sort it properly? The DataView.Sort always break
> the line when it sees a comma. Then it complains about field name being
> invalid. I've tried quoting my field name with '"' or ''' but they all

fail
> the same way.
>
> any idea how to make it work?
>
> Mone


Short of suggesting to not have column names with commas, I would do
something like this:

As far as I know, the Sort property will not support column names with
commas. It won't let you escape the comma. So instead, you can add an
expression column to the source table. If you are trying to sort on a
column named "Foo,Bar", then you could do this:

myTable.Columns.Add( "FooBarCopy",
custTable.Columns["Foo,Bar"].DataType, "[Foo,Bar]" );

This creates a column that uses the Expression property to reference to
the data in the original column. Now you can sort on the new column:

myView.Sort = "FooBarCopy";

Erik


 
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
Adding more sort fields to the SORT Dialog Box Doug V. Microsoft Excel Misc 3 6th Oct 2008 07:30 PM
Sort Form Records Using Field Names from Combo Box =?Utf-8?B?SyBDbGF1YmVyZw==?= Microsoft Access Forms 1 10th Oct 2006 03:05 AM
Second sort field for Artist Names - Douglas? Penny Microsoft Access 2 14th Apr 2005 01:33 PM
Sort field names in table design =?Utf-8?B?SXJlbmU=?= Microsoft Access 21 13th Apr 2005 11:40 PM
Selecting a report's sort order & sort fields at runtime Alp Microsoft Access Reports 5 2nd Jan 2005 06:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:24 PM.