VBA code for Rich text (1 Viewer)

rgparpaccessworld

New member
Local time
Today, 07:45
Joined
Sep 6, 2020
Messages
1
I have Access 2016


I have a form name Patient Billing with several text and each text has several button
Below is one of them:
I have text box - HospHx – format property set on Rich Text

Command button 1: [HospHx] = [HospHx] & "## RS = " & vbCrLf & UCase("Tolerating with no dysynchrony") & vbCrLf & "Secretion – minimal” & vbCrLf & ""
Command Button 2: [HospHx] = [HospHx] & vbCrLf & "" & "## CNS = " & vbCrLf & "Sedation - " & vbCrLf & "**Mentation - " & vbCrLf & "**Pupil - reactive" & vbCrLf & ""

When I click Command button 1 and 2, I get following which is jumble up in one sentence in Text box HospHx :

## RS = TOLERATING WITH NO DYSYNCHRONY Secretion - minimal ## CNS = Sedation - **Mentation - **Pupil - reactive


I can use “<div>” = [HospHx] = [HospHx] & “,<div>” & "## RS = " & “<div>” & vbCrLf & “<div>” & UCase("Tolerating with no dysynchrony") & vbCrLf &“<div>” & "Secretion – minimal” & “<div>” & vbCrLf & ""
When I click button command 1 and 2 - I get following in Text box - HospHx
## RS =
TOLERATING WITH NO DYSYNCHRONY
Secretion - minimal

## CNS =
Sedation -
**Mentation -
**Pupil – reactive

Is there a different way of using VBA code to avoid manually adding “<div>” to all my button, as I have several button in the same 'form Patient Billing'
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 05:45
Joined
Aug 30, 2003
Messages
36,129
I use <br>, but either way you could do a find and replace to replace vbCrLf with "<div>"
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:45
Joined
Oct 29, 2018
Messages
21,505
Hi. Welcome to AWF!

This other thread might be related to this one.

 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:45
Joined
May 7, 2009
Messages
19,246
create a UDF to add those "<div>" to the text:

Public Function fAddDiv(byRef strOriginalText As Variant, byVal strAppendText As String)
strOrignalText = strOriginalText & vbNullString
strOriginalText = strOriginalText & "<div>" & strAppendText & "</div>"
End Function
 

CJ_London

Super Moderator
Staff member
Local time
Today, 13:45
Joined
Feb 19, 2013
Messages
16,638
just curious - why are you using richtext when not using bold/colour etc? vbcrlf is not a rich text code. change your control format to plain text and the data will display on multiple lines as you appear to want
 

Users who are viewing this thread

Top Bottom