Inserting textbox of "Bob & Jake & Jill" into rft field results in "Bob& Jake & Jill" (1 Viewer)

bignose2

Registered User.
Local time
Today, 14:14
Joined
May 2, 2010
Messages
204
Hi,

I have a rtf field (emailreply) on a form.

It is made up of simple strings & other fields
e.g.
me!emailreply = "hello" & me!Names & "how are you" & "this is your address" & me!Address

me!Names is a field & textbox (normal NON rtf)

if Me!Names is "Bob & Jake & Jill", when me!emailreply is constructed it shows "Bob& Jake & Jill".

i.e. removes the first space in front of the FIRST &

weirdly (to me) it only does it to the first, Jake & Jill is normal.

I am sure I can find ways to test & replace/add but would quite like to know what is happening and if a simple way to fix.
I have this me!Names in dozens of long liens of code making up sentences.

tried plaintext(me!names) & having another field that is rtf and = me!Names & insert this rft field instead, no difference.

thanks I/A
 

isladogs

CID VIP
Local time
Today, 14:14
Joined
Jan 14, 2017
Messages
16,408
I've not tried this but what happens if you use a double space after Bob?
Does it reduce it to a single space?
 

bignose2

Registered User.
Local time
Today, 14:14
Joined
May 2, 2010
Messages
204
Hi,

Yes, double space after Bob is reduce to single space,

I can program to sort but just seems odd (and unnecessary), especially as does not do it to the others after, I could sort of appreciate the ampersand causing issues but why only the 1st.
 

Minty

AWF VIP
Local time
Today, 14:14
Joined
Jul 26, 2013
Messages
9,371
The ampersand is a weird character in Access.

Put "Me && My Shadow" into the caption property of a label.
1615648973062.png

Then try it with one & ...
1615649018560.png


I'm sure I read about why this happens but cannot for the life of me find any references to it.
 

bignose2

Registered User.
Local time
Today, 14:14
Joined
May 2, 2010
Messages
204
In the caption I understand why especially on buttons etc. to act as if pressing using the alt key but why on the actual underlying data.

I know rtf fields do behave differently with all the html and perhaps inserting a non-rft into a rft field can really complicate & cause unpredictable results but this does not make much sense.
 

bignose2

Registered User.
Local time
Today, 14:14
Joined
May 2, 2010
Messages
204
Even more confusing, I have it set up so I can view exactly the same data but on a plaintext control so it shows all the rtf/html tags,
as below, just different names, Bonnie & Lulu & belle, you can see the space is there

<div>I am pleased to <strong>confirm</strong> the booking(s) as below.</div>Sat 01-May-21 To Mon 03-May-21<br><br>Bonnie & Lulu & belle<br>Poodle & Yorkie

view the same in a RichText control (my normal viewing method) and there is no gap 'Bonnie& Lulu & belle'


ignore the <br> etc, I know a mix here with the <div> also but I do send sometimes plain but sure this does not have any bearing on this issue.
 

bignose2

Registered User.
Local time
Today, 14:14
Joined
May 2, 2010
Messages
204
Just for ref. rather given up trying to find out but if anyone does know off hand,

Replace(Me!PetNames, "&", " &", , 1)

does fix easily, although I have a lot of places I need to apply.

thanks for any replies.
 

bignose2

Registered User.
Local time
Today, 14:14
Joined
May 2, 2010
Messages
204
The Saga continues, re-visiting anyway.
Mostly use of this field/data is RTF, emails I send out etc.
However I also now want to remove the html when it needs to be a TEXT/SMS.

on a mission now to find out what is going on..

All below is using the same me!LetterSource, a rtf field in a table

I am looking at now, in a rft textbox, 1 space after Bonnie.
Bonnie & Lulu & belle
Poodle & Yorkie & Cat

the same data source viewed in a plain text textbox, has 2 spaces after Bonnie (this is the extra space I added to fix)
Bonnie & Lulu & belle<br>Poodle & Yorkie & Cat<br><div>&nbsp;</div>

If Iterate through the text, I can see the two asc 32's
B 66
o 111
n 110
n 110
i 105
e 101
32
32
& 38
32
L 76
u 117
l 108
u 117
32
& 38
32
b 98
e 101
l 108
l 108
e 101
< 60

If I email this or export to a text file it has the two spaces.

As soon as I edit the text & make any change typing in the textbox, it reverts to 1 space, as view initially.
The problem is if I have just one space originally, as it should be really, it reverts to no spaces. which was my problem from the start.

Either way something odd is happening.

I have refreshed, exited the program, come back in, the same data loaded showing 1 space but still 2 in the underlying table or viewed any other way. would not be too much of issue but as I say as soon as I reply & make any changes anything with this suddenly have no spaces.
tried..
me!LetterSource.value
me!LetterSource.text
DoCmd.RunCommand acCmdSaveRecord

Tried so many different variations!

Any ideas
 

Users who are viewing this thread

Top Bottom