Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I switch order of textbox lines 2

Status
Not open for further replies.

Lhuffst

Programmer
Jun 23, 2003
503
US
Hi
I have a text box that has 2 separate lines.
Service Area: xxxxxx
Health Dept: xxxxx

Users want to switch order to

Health Dept: xxxx
Service Area: xxxx

Since each line can have different lenghts, what is the easiest way to do this? Thanks lhuffst
 


uh, HOW is this textbox loaded?

and WHY is a TextBox being used like this? a TextBox is designed to be a control for user input???

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
We converted an old system to a new cots program and this is how old data was initially requested to be loaded. In the future they will have to do the input themselves but since we converted 300,000+ records, I wanted to see if we could make the initial flip.

As to how the vendor loaded it, I can't answer, I just know that is what I see when I look at the table. Any ideas on how this could be done?
 


Code:
dim a 

a = split(YourTextBox.Text, vblf)

YourTextBox.Text = a(1) & vblf & a(0)
assuming that a LineFeed separates the two lines.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Don't you want to change the values stored in a field in your table? Are you hoping to swap anything before a carriage return/line feed with anything after it?

Duane
Hook'D on Access
MS Access MVP
 
Hi yes I do want to update the table swapping the text before and after the carriage return.

Is it easier to do in a query?
 


That's why I was asking HOW the text box is loaded???

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
SkipVought - I apologize. I was not the one who loaded the textbox so I have no idea how they did it. For me, I just want to flip the data the easiest way possible.

What I just did was to export the table to a blank database so I can do trial and error since this is a production system. That way I can't mess anything up :)
 
I like Skip's use of Split() but had an issue getting it to work in a query. Consider the following query to display the conversion. Change this select query to an update query to store the actual changes. I would work with a test table first.
Code:
SELECT NoTableName.FieldNoNameGiven,
 Mid([FieldNoNameGiven],InStr([FieldNoNameGiven], Chr(13)+Chr(10))+2) & 
Chr(13) & Chr(10) & 
Left([FieldNoNameGiven],InStr([FieldNoNameGiven], Chr(13)+Chr(10))-2) AS NewValue
FROM NoTableName
WHERE (((NoTableName.FieldNoNameGiven) Like "*" & Chr(13) & Chr(10) & "*"));

Duane
Hook'D on Access
MS Access MVP
 

@Duane,

There was nothing in the question, explicit or implicit, regarding SQL, forum not withstanding.

The OP appears NOT to have access to the Access source code.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top