473,569 Members | 2,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sorting Delimited Text in a Text Box

Access 2003. The situation is this: I have a "criteria selection form"
in which there are a many different criteria, mostly displayed as combo
and text boxes in which a user can enter stuff, click an associated
button and that criteria becomes part of the where clause of a select
statement. The selected criteria is stored on a hidden form and when
the user is ready to run their report(s), a button action goes through
the hidden form and builds a select statement.

For example, say buildings has a partial combo box list which shows:

PK (hidden) Bldg Name
1 Arts Building
2 Biology Building
6 Chemistry Building
8 Student Building

A user want to look at records from Chemistry and Arts, so the hidden
form "SQL WHERE STAEMENT" field would store values like this when Arts
was selected:

BLDG_PK = 1

Then, altered to look like this when Chemistry is selected:

BLDG_PK IN (1, 6)

And so on as more buildings may or may not be selected.

That's all well and good. However, along with the "SQL WHERE STAEMENT"
field, there's also a "CRITERIA DESCRIPTION" field. This adds the
Building Names so that the user sees a criteria view somewhere that is
also reproduced as a report header which lists the buildings selected.

I'm using a line break, vbcrlf, as a delimiter here. So if the user
selected in the same order as in the example, the "CRITERIA DESCRIPTION"
field will look like this:

Arts Building
Chemistry Building

But what if the user selects Chemistry first, then arts? What is stored
in the "CRITERIA DESCRIPTION" field will be:

Chemistry Building
Arts Building

What I am trying to figure out is how to sort this, alphabetically.

Any ideas or gentle/violent prods? And yes, I know I have to take care
of possible duplicates which is easy enough to do... 8)

Thanks very much in advance.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #1
2 2809
You need to do your sorting as each selection is made. How about putting the
selections in a collection rather that your "CRITERIA DESCRIPTION" field and
sort as you add to the collection. That way you have a simple list. Then
when you need the list in the report header, you build your "CRITERIA
DESCRIPTION" string using a line break, vbcrlf, as a delimiter. You need a
sub procedure to do this which gets called after each selection. Obviously
it does not get called after the first selection. To sort, you take the
latest selection and walk the collection inserting the latest selection
immediately following the first item in the collection list that has a sort
value less that the latest selection. Inserting an item means assigning an
index number to the selection. Sounds complicated until you start working it
out!!

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdata sheet.com
www.pcdatasheet.com

If you don't get the help you need in the newsgroup, I can help you for a
very reasonable fee.
Over 1000 Access users have come to me for help.
Remember that a lone man built the Ark. A large group of professionals built
the Titanic.
"Tim Marshall" <TI****@PurpleP andaChasers.Moe rtherium> wrote in message
news:dj******** **@coranto.ucs. mun.ca...
Access 2003. The situation is this: I have a "criteria selection form"
in which there are a many different criteria, mostly displayed as combo
and text boxes in which a user can enter stuff, click an associated button
and that criteria becomes part of the where clause of a select statement.
The selected criteria is stored on a hidden form and when the user is
ready to run their report(s), a button action goes through the hidden form
and builds a select statement.

For example, say buildings has a partial combo box list which shows:

PK (hidden) Bldg Name
1 Arts Building
2 Biology Building
6 Chemistry Building
8 Student Building

A user want to look at records from Chemistry and Arts, so the hidden form
"SQL WHERE STAEMENT" field would store values like this when Arts was
selected:

BLDG_PK = 1

Then, altered to look like this when Chemistry is selected:

BLDG_PK IN (1, 6)

And so on as more buildings may or may not be selected.

That's all well and good. However, along with the "SQL WHERE STAEMENT"
field, there's also a "CRITERIA DESCRIPTION" field. This adds the
Building Names so that the user sees a criteria view somewhere that is
also reproduced as a report header which lists the buildings selected.

I'm using a line break, vbcrlf, as a delimiter here. So if the user
selected in the same order as in the example, the "CRITERIA DESCRIPTION"
field will look like this:

Arts Building
Chemistry Building

But what if the user selects Chemistry first, then arts? What is stored
in the "CRITERIA DESCRIPTION" field will be:

Chemistry Building
Arts Building

What I am trying to figure out is how to sort this, alphabetically.

Any ideas or gentle/violent prods? And yes, I know I have to take care of
possible duplicates which is easy enough to do... 8)

Thanks very much in advance.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me

Nov 13 '05 #2
I'm using a line break, vbcrlf, as a delimiter here. So if the user
selected in the same order as in the example, the "CRITERIA DESCRIPTION"
field will look like this:

Arts Building
Chemistry Building

But what if the user selects Chemistry first, then arts? What is stored
in the "CRITERIA DESCRIPTION" field will be:

Chemistry Building
Arts Building

What I am trying to figure out is how to sort this, alphabetically.


Maybe I'm misunderstandin g, but it sounds like this is a job for a list box.
Why not have a list box with a rowsource generated on the fly?

If at some point you need to read the text from the Criteria Description,
you could either

- create recordset from the same source as the list box's rowsource
or
- iterate through the rows of the list box and concatenate, if you want to
create a string

It just seems unnecessary to create a string with line breaks and worry
about its appearance, etc., when you can just feed some SQL to a control and
let Access take over.

HTH,

Bruce
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
293
by: James P | last post by:
Hi All, I have an xml file as listed below. This is a list of scripts. Some of the scripts depend on the output of other scripts. I want to sort this xml in such a way that the scripts are listed in the correct order of execution. I created an IComparer class and implememted the Compare method. I am calling Array.Sort on an XmlNode array....
8
2251
by: nidhog | last post by:
Hello guys, I made a script that extracts strings from a binary file. It works. My next problem is sorting those strings. Output is like: ---- snip ---- 200501221530
3
7022
by: Ben | last post by:
Hi all - I am having a bit of trouble and thought maybe someone in this group could shed some light. Here's the skinny... I am creating an automated process to import a bunch of text files into Access. I want to avoid creating a separate "Spec" for each file (there are over 180 files) and instead want to code my own dynamic importing...
19
25438
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to sort columns based on the column header the user has clicked in both Ascending and Descending formats.
1
8174
by: Fordraiders | last post by:
vb.net 2003 Office 2003 What I have: C:\TestData\Input.txt Text File Pipe Delimited : 4 columns Of data example: 00001|NO BRAND NAME ASSIGNED|6DU27|M3-.5 X 6 FLAT HD SOCKET CAP SCREW, CL10.9, ALLOY STEEL 00002|NO BRAND NAME ASSIGNED|6DU28|M3-.5 X 8 FLAT HD SOCKET CAP SCREW,
2
2115
by: Ron | last post by:
so if my textbox is named textbox1 and my listbox is named ltsdisplay, for the button that would make this all happen I would just need to: lstdisplay.items.textbox1(delimited.Split(",".ToCharArray())) is that right? or no? I try this and I get an error...
13
2789
by: JJ | last post by:
I have a need to input a large tab delimited text file, which I will parse to check it has the expected columns, before allowing the user to submit it to the database. The user may paste the file into a textbox, or upload it (haven't decided yet). The problem I have is that the text file consists of around 3000 lines, and I want to display...
1
1426
by: aram535 | last post by:
Hi, I'm reading in a delimeted text file (X rows, 4 columns) in this case tab delimited. I would like the array to be sorted in the array. This is the best I have come up with, but it seems very harsh. Is there no easier way of sorting an array? String tempData; tempData = new String;
5
4916
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums there are, it crashes. There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)? Here is a link:...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.