Concatenating Rich Textbox Controls Into A Single File

N

Neil

Using the MS Rich Textbox Control 6.0 in Access 2000, I need to concatenate
several RTB controls into a single RTF file. Sometimes two strings will be
side-by-side; other times they need to be separated by a hard return.

For example, say I have the following 4 RTB controls in my form:

RTB1 = "abcd"
RTB2 = "efgh"
RTB3 = "ijkl"
RTB4 = "mnop"

The resulting RTF document might need to look like this:

abcdefgh

ijkl

mnop

Using the SaveFile method works great for a single RTB control. But how can
I concatenate the contents of two or more controls into a single RTF file,
and how can I insert hard returns between sets of text?

Thanks!

Neil
 
K

King Ron

Using the MS Rich Textbox Control 6.0 in Access 2000, I need to concatenate
several RTB controls into a single RTF file. Sometimes two strings will be
side-by-side; other times they need to be separated by a hard return.

For example, say I have the following 4 RTB controls in my form:

RTB1 = "abcd"
RTB2 = "efgh"
RTB3 = "ijkl"
RTB4 = "mnop"

The resulting RTF document might need to look like this:

abcdefgh

ijkl

mnop

Using the SaveFile method works great for a single RTB control. But how can
I concatenate the contents of two or more controls into a single RTF file,
and how can I insert hard returns between sets of text?

Thanks!

Neil

In this case, and assuming the format is constant:

wkText = RTB1 & RTB2 & vbCrLf & vbCrLf & RTB3 & vbCrLf & vbCrLf &
RTB4

vbCrLF is the VB constant shorthand for the carriage return/linefeed
combination.

You could also concatenate 'Chr$(13) & Chr$(10)' instead of the
constant. If the structure is variable, the actual concatenation
sequence will be more complex but usually solvable. The inline 'If'
statement is quite useful for these puzzles.

iif([something],"concatenate" & "some things","concatenate" & "other"
& "things")

Lucks to yas!

Ron King of Chi
 
N

Neil

No, we're dealing with rich textboxes here. Each box is a self-contained RTF
statement. You can't concatenate them with vbCrLf.


King Ron said:
Using the MS Rich Textbox Control 6.0 in Access 2000, I need to
concatenate
several RTB controls into a single RTF file. Sometimes two strings will
be
side-by-side; other times they need to be separated by a hard return.

For example, say I have the following 4 RTB controls in my form:

RTB1 = "abcd"
RTB2 = "efgh"
RTB3 = "ijkl"
RTB4 = "mnop"

The resulting RTF document might need to look like this:

abcdefgh

ijkl

mnop

Using the SaveFile method works great for a single RTB control. But how
can
I concatenate the contents of two or more controls into a single RTF
file,
and how can I insert hard returns between sets of text?

Thanks!

Neil

In this case, and assuming the format is constant:

wkText = RTB1 & RTB2 & vbCrLf & vbCrLf & RTB3 & vbCrLf & vbCrLf &
RTB4

vbCrLF is the VB constant shorthand for the carriage return/linefeed
combination.

You could also concatenate 'Chr$(13) & Chr$(10)' instead of the
constant. If the structure is variable, the actual concatenation
sequence will be more complex but usually solvable. The inline 'If'
statement is quite useful for these puzzles.

iif([something],"concatenate" & "some things","concatenate" & "other"
& "things")

Lucks to yas!

Ron King of Chi
 
K

King Ron

No, we're dealing with rich textboxes here. Each box is a self-contained RTF
statement. You can't concatenate them with vbCrLf.


In this case, and assuming the format is constant:
wkText = RTB1 & RTB2 & vbCrLf & vbCrLf & RTB3 & vbCrLf & vbCrLf &
RTB4
vbCrLF is the VB constant shorthand for the carriage return/linefeed
combination.
You could also concatenate 'Chr$(13) & Chr$(10)' instead of the
constant. If the structure is variable, the actual concatenation
sequence will be more complex but usually solvable. The inline 'If'
statement is quite useful for these puzzles.
iif([something],"concatenate" & "some things","concatenate" & "other"
& "things")
Lucks to yas!
Ron King of Chi

Well that water quickly got up over my head...

I'll have to play with one o them a lil' bit and get back atchas.

R, KOC
 
Y

Yvonne Anderson

What it is this group, and why is it appearing on my computer?

Yvonne Michele Anderson
(e-mail address removed)


No, we're dealing with rich textboxes here. Each box is a self-contained RTF
statement. You can't concatenate them with vbCrLf.


Using the MS Rich Textbox Control 6.0 in Access 2000, I need to
concatenate
several RTB controls into a single RTF file. Sometimes two strings will
be
side-by-side; other times they need to be separated by a hard return.
For example, say I have the following 4 RTB controls in my form:
RTB1 = "abcd"
RTB2 = "efgh"
RTB3 = "ijkl"
RTB4 = "mnop"
The resulting RTF document might need to look like this:



Using the SaveFile method works great for a single RTB control. But how
can
I concatenate the contents of two or more controls into a single RTF
file,
and how can I insert hard returns between sets of text?


In this case, and assuming the format is constant:
wkText = RTB1 & RTB2 & vbCrLf & vbCrLf & RTB3 & vbCrLf & vbCrLf &
RTB4
vbCrLF is the VB constant shorthand for the carriage return/linefeed
combination.
You could also concatenate 'Chr$(13) & Chr$(10)' instead of the
constant. If the structure is variable, the actual concatenation
sequence will be more complex but usually solvable. The inline 'If'
statement is quite useful for these puzzles.
iif([something],"concatenate" & "some things","concatenate" & "other"
& "things")
Lucks to yas!
Ron King of Chi

Well that water quickly got up over my head...

I'll have to play with one o them a lil' bit and get back atchas.

R, KOC
 
N

Neil

Why don't you tell us. None of us have access to your computer, so we can't
tell you why the things that are on your computer are on your computer.


Yvonne Anderson said:
What it is this group, and why is it appearing on my computer?

Yvonne Michele Anderson
(e-mail address removed)


No, we're dealing with rich textboxes here. Each box is a self-contained
RTF
statement. You can't concatenate them with vbCrLf.



Using the MS Rich Textbox Control 6.0 in Access 2000, I need to
concatenate
several RTB controls into a single RTF file. Sometimes two strings
will
be
side-by-side; other times they need to be separated by a hard return.

For example, say I have the following 4 RTB controls in my form:

RTB1 = "abcd"
RTB2 = "efgh"
RTB3 = "ijkl"
RTB4 = "mnop"

The resulting RTF document might need to look like this:

abcdefgh

ijkl

mnop

Using the SaveFile method works great for a single RTB control. But
how
can
I concatenate the contents of two or more controls into a single RTF
file,
and how can I insert hard returns between sets of text?

Thanks!

Neil

In this case, and assuming the format is constant:

wkText = RTB1 & RTB2 & vbCrLf & vbCrLf & RTB3 & vbCrLf & vbCrLf &
RTB4

vbCrLF is the VB constant shorthand for the carriage return/linefeed
combination.

You could also concatenate 'Chr$(13) & Chr$(10)' instead of the
constant. If the structure is variable, the actual concatenation
sequence will be more complex but usually solvable. The inline 'If'
statement is quite useful for these puzzles.

iif([something],"concatenate" & "some things","concatenate" & "other"
& "things")

Lucks to yas!

Ron King of Chi

Well that water quickly got up over my head...

I'll have to play with one o them a lil' bit and get back atchas.

R, KOC
 
S

Stephen Lebans

If you do not want to work directly with the RTF encoding then simply
cocatenate the values of the existing RTF controls into a new RTF control.
Use the Selxxx props/methods to select the complete contents of one control,
grab the RTF Selection, set your insertion point within the new RTF control,
set the SelText prop of the new control, and so on.
Add another control that contains nothing but a carriage retunr and follow
the same logic as above to select and copy the contents into the new
cocatenated RTF control.


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


King Ron said:
No, we're dealing with rich textboxes here. Each box is a self-contained
RTF
statement. You can't concatenate them with vbCrLf.


Using the MS Rich Textbox Control 6.0 in Access 2000, I need to
concatenate
several RTB controls into a single RTF file. Sometimes two strings
will
be
side-by-side; other times they need to be separated by a hard return.
For example, say I have the following 4 RTB controls in my form:
RTB1 = "abcd"
RTB2 = "efgh"
RTB3 = "ijkl"
RTB4 = "mnop"
The resulting RTF document might need to look like this:



Using the SaveFile method works great for a single RTB control. But
how
can
I concatenate the contents of two or more controls into a single RTF
file,
and how can I insert hard returns between sets of text?


In this case, and assuming the format is constant:
wkText = RTB1 & RTB2 & vbCrLf & vbCrLf & RTB3 & vbCrLf & vbCrLf &
RTB4
vbCrLF is the VB constant shorthand for the carriage return/linefeed
combination.
You could also concatenate 'Chr$(13) & Chr$(10)' instead of the
constant. If the structure is variable, the actual concatenation
sequence will be more complex but usually solvable. The inline 'If'
statement is quite useful for these puzzles.
iif([something],"concatenate" & "some things","concatenate" & "other"
& "things")
Lucks to yas!
Ron King of Chi

Well that water quickly got up over my head...

I'll have to play with one o them a lil' bit and get back atchas.

R, KOC
 
N

Neil

Thanks, Stephen! That was just what I was looking for. Being a newbie with
RTFs, I didn't think to use the Sel properties. That worked great. Only one
problem.

When I concatenate two pieces of text that are supposed to be in the same
paragraph, side by side, they end up with a hard return between them.

For example, RTF1="abc" and RTF2="def", and I want the result to be
"abcdef". Instead I get:

abc
def

Here's my code (rtfCompilation is the control being used for concatenation):

Me.rtfCompilation = ""

Me.rtf1.SelStart = 0
Me.rtf1.sellength = Len(Me.rtf1)
Me.rtfCompilation.SelText = Me.rtf1.SelRTF

Me.rtf2.SelStart = 0
Me.rtf2.sellength = Len(Me.rtf2)
Me.rtfCompilation.SelStart = Len(Me.rtfCompilation)
Me.rtfCompilation.SelText = Me.rtf2.SelRTF

I also tried the above with Me.rtfCompilation.SelStart =
Len(Me.rtfCompilation) + 1. Results were the same.

Thanks!

Neil


Stephen Lebans said:
If you do not want to work directly with the RTF encoding then simply
cocatenate the values of the existing RTF controls into a new RTF control.
Use the Selxxx props/methods to select the complete contents of one
control, grab the RTF Selection, set your insertion point within the new
RTF control, set the SelText prop of the new control, and so on.
Add another control that contains nothing but a carriage retunr and follow
the same logic as above to select and copy the contents into the new
cocatenated RTF control.


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


King Ron said:
No, we're dealing with rich textboxes here. Each box is a self-contained
RTF
statement. You can't concatenate them with vbCrLf.



Using the MS Rich Textbox Control 6.0 in Access 2000, I need to
concatenate
several RTB controls into a single RTF file. Sometimes two strings
will
be
side-by-side; other times they need to be separated by a hard return.

For example, say I have the following 4 RTB controls in my form:

RTB1 = "abcd"
RTB2 = "efgh"
RTB3 = "ijkl"
RTB4 = "mnop"

The resulting RTF document might need to look like this:

abcdefgh

ijkl

mnop

Using the SaveFile method works great for a single RTB control. But
how
can
I concatenate the contents of two or more controls into a single RTF
file,
and how can I insert hard returns between sets of text?

Thanks!

Neil

In this case, and assuming the format is constant:

wkText = RTB1 & RTB2 & vbCrLf & vbCrLf & RTB3 & vbCrLf & vbCrLf &
RTB4

vbCrLF is the VB constant shorthand for the carriage return/linefeed
combination.

You could also concatenate 'Chr$(13) & Chr$(10)' instead of the
constant. If the structure is variable, the actual concatenation
sequence will be more complex but usually solvable. The inline 'If'
statement is quite useful for these puzzles.

iif([something],"concatenate" & "some things","concatenate" & "other"
& "things")

Lucks to yas!

Ron King of Chi

Well that water quickly got up over my head...

I'll have to play with one o them a lil' bit and get back atchas.

R, KOC
 
L

Larry Linson

Yvonne Anderson said:
What it is this group, and why is it appearing on my computer?

This is a USENET newsgroup devoted to questions and answers about Microsoft
Access.

The only reason I can think that it would be appearing on your computer is
that you, or someone else, selected it in your newsreader software. If you
are in the habit of logging on to your computer and then walking away, that
could explain it.

But, in any case, if you open your newsreader and take appropriate steps to
unsubscribe, it should go away.

Larry Linson
Microsoft Access MVP
 
N

Neil

You're a better person than me, Larry. :)

Larry Linson said:
This is a USENET newsgroup devoted to questions and answers about
Microsoft Access.

The only reason I can think that it would be appearing on your computer is
that you, or someone else, selected it in your newsreader software. If
you are in the habit of logging on to your computer and then walking away,
that could explain it.

But, in any case, if you open your newsreader and take appropriate steps
to unsubscribe, it should go away.

Larry Linson
Microsoft Access MVP
 
N

Neil

Hey, Stephen. Well, I stumbled upon the solution to my problem with unwanted
hard returns appearing between two segements of concatenated text (previous
message). Seems that the "" I put at the beginning of the code (to clear the
compilation rich textbox control) was causing it.

Thus, changing the code from this:

Me.rtfCompilation = ""

Me.rtf1.SelStart = 0
Me.rtf1.sellength = Len(Me.rtf1)
Me.rtfCompilation.SelText = Me.rtf1.SelRTF

Me.rtf2.SelStart = 0
Me.rtf2.sellength = Len(Me.rtf2)
Me.rtfCompilation.SelStart = Len(Me.rtfCompilation)
Me.rtfCompilation.SelText = Me.rtf2.SelRTF

to this:

Me.rtf1.SelStart = 0
Me.rtf1.sellength = Len(Me.rtf1)
Me.rtfCompilation = Me.rtf1.SelRTF

Me.rtf2.SelStart = 0
Me.rtf2.sellength = Len(Me.rtf2)
Me.rtfCompilation.SelStart = Len(Me.rtfCompilation)
Me.rtfCompilation.SelText = Me.rtf2.SelRTF

resolved the problem. (Removed the first line and changed the fourth line
from "rtfCompilation.SelText =" to "rtfCompilation =".)

Still not sure why the "" at the beginning caused the extra hard return to
appear at the end of that block. But at least it's cleared up.

<>

On a separate note, I realized that since I'm concatenating the entire
contents of the controls, that I could just use the TextRTF property, rather
than the SelRTF property. Thus, I modified the above code further to:

Me.rtfCompilation = Me.rtf1.TextRTF
Me.rtfCompilation.SelStart = Len(Me.rtfCompilation)
Me.rtfCompilation.SelText = Me.rtf2.TextRTF

Do you see any problem with that?

Thanks!!

Neil



Stephen Lebans said:
If you do not want to work directly with the RTF encoding then simply
cocatenate the values of the existing RTF controls into a new RTF control.
Use the Selxxx props/methods to select the complete contents of one
control, grab the RTF Selection, set your insertion point within the new
RTF control, set the SelText prop of the new control, and so on.
Add another control that contains nothing but a carriage retunr and follow
the same logic as above to select and copy the contents into the new
cocatenated RTF control.


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


King Ron said:
No, we're dealing with rich textboxes here. Each box is a self-contained
RTF
statement. You can't concatenate them with vbCrLf.



Using the MS Rich Textbox Control 6.0 in Access 2000, I need to
concatenate
several RTB controls into a single RTF file. Sometimes two strings
will
be
side-by-side; other times they need to be separated by a hard return.

For example, say I have the following 4 RTB controls in my form:

RTB1 = "abcd"
RTB2 = "efgh"
RTB3 = "ijkl"
RTB4 = "mnop"

The resulting RTF document might need to look like this:

abcdefgh

ijkl

mnop

Using the SaveFile method works great for a single RTB control. But
how
can
I concatenate the contents of two or more controls into a single RTF
file,
and how can I insert hard returns between sets of text?

Thanks!

Neil

In this case, and assuming the format is constant:

wkText = RTB1 & RTB2 & vbCrLf & vbCrLf & RTB3 & vbCrLf & vbCrLf &
RTB4

vbCrLF is the VB constant shorthand for the carriage return/linefeed
combination.

You could also concatenate 'Chr$(13) & Chr$(10)' instead of the
constant. If the structure is variable, the actual concatenation
sequence will be more complex but usually solvable. The inline 'If'
statement is quite useful for these puzzles.

iif([something],"concatenate" & "some things","concatenate" & "other"
& "things")

Lucks to yas!

Ron King of Chi

Well that water quickly got up over my head...

I'll have to play with one o them a lil' bit and get back atchas.

R, KOC
 

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