Link to home
Start Free TrialLog in
Avatar of mtrussell
mtrussell

asked on

Align text in rich text format in access 2010

I have a rich text field and have a bullet point which indents the text on the first line but the second line is in wrap text so the first word is under the bullet point instead of the text of the first line.  How do you align text in rich text?
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Unfortunately the capabilities of RTF in Access are somewhat limited and Hanging Indents fall into one of those limitations.  There are workarounds but each has disadvantages:

1) manually insert spaces at the beginning of each wrap around.  
- disadvantage: has to be manually done and editing the text can cause the spaces to be moved as well.

2) embed or link to a Word Document OLE object using the Unbound Frame Object control.
- disadvantage: difficult to incorporate fields from your recordsource.

3) use 3rd party ActiveX control such as Total Access Memo
- disadvantage: it's not cheap

There may be other alternatives, Lebans RTF Memo for instance, but I'm not sure if his supports anything past 2003 or does hanging indents.  Other experts may hopefully have other ideas.

Ron
Access has very limited formatting capability for Rich Text fields.

I have seen comments elsewhere that creating the text in a word processor, with hanging indents and then pasting into your table might work, but I was never able to get this functionality to work properly.
Avatar of mtrussell
mtrussell

ASKER

I have seen these options but they don't work very well.  If I use plain text is there a work around?  This seems to be a pretty big limitation for an Access report.... :(
Well, plain text will not allow bullets nor hanging indents.  If you use plain text in your report, what problem were you experiencing that you needed to use bullets?
This is an executive report and I have three bullet points and the report looks unprofessional with the wrapped text.  Can I link any Word references and do this using a Word control?

I have been building a database for a couple months and have executive reports that I need to use, everything looks right except for the wrapped text.  

Yeah, it looks like plain text won't work either in this.  Can I do some sort of a field length calculation and automatically and a carriage return or something?

This could be bad...
The problem with field length calculation is that you have to use a fixed width font.  These fonts do not look professional so I'm sure you won't want that.  Does the text that goes here only need to be changed in design or does it have to change dynamically depending on the record?
dynamically.  There is a column and for each record there is text with bullet points.  All the text is descriptive so there isn't a consistent output from a programming perspective.  The structure of the field is; summary text, carriage return, bullet points.
The only thing I can think of then is having a word document that uses it's mail merge feature to pull in the data from your table.  Then use the Unbound Frame Control link to this Word document.
but won't the fields have to be exactly the same in Word and Access for this to work?  I have never done this before.

Would any PP or Word references work in this?  It looks grim.  :(
a bit more work, but you could automate Word and paste your "data" into a Word document to create your executive report.
but won't the fields have to be exactly the same in Word and Access
When you set up a mail merge you will be using the actual fields from your table so yes, they will be the same.
Is there a tutorial on how to do this you could share?  It seems like a lot of work but it might be the only way of doing it...  also, is there any vba code that loops this automatically or am I going to have to set this up manually every time I want to print the report?
You would need to repopulate a temp table each time you want a new report.  This is the table you would use in Word as your data source.  You could find tutorials on merging with Access database anywhere.  Here's one I just found:
https://www.youtube.com/watch?v=KkR_azixHZk
Thanks.  Here is another approach I just thought of... can I use a combination of everytime a bullet is found the Len() function is used to determine the length of the text string and then when it gets to the edge of the box it finds the previous last space it adds a left return carriage and a few spaces to make the rest of the test look like it fits?  The length of the box is 7.196cm.  Shouldn't there be a way of mathematically figuring this out?  I am not at a point in my VBA skills to do it but this seems to be doable...  

I know I am stretching here....  just was curious...
Again you'd be back to using fixed width fonts like Lucinda Console or Courier New, neither of which look good in a professional document.  If you were using proportional fonts, it would be difficult to figure out where the wrap happens and the number of spaces needed to match the line above.
This doesn't have to be perfect.  I am fine with the right being a bit off... so if we let the code think it is using one of the two above fonts, and it rolls back and finds the first space when the text goes beyond the space of the text box, is this doable?
ASKER CERTIFIED SOLUTION
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also if you want to go that route, I would suggest you open another question and mention specifically that is what you'd like so that another expert could figure out the coding for that.
The fonts look terrible but for a fixed length perspective I would just be using it for the math.  Once the code figures out the break I can reset it back to Courier.  Wouldn't that work?
No it wouldn't work.  The width of each character in proportional fonts differs so as soon as you change fonts, your formatting will be all off.
Let me see.  To me the code just is looking for the word that goes over the limit and then will return that word technically.  I get the font will change this but it then would technically return the previous word and the right would be off a bit.  I can control the number of spaces on the left.

I get this might not work but it is a mathematical formula more than formatting at this point... I think...

I'm reaching here... I get this...
Do a quick test.  Go ahead and manually add spaces while using Courier New. Then one you have it looking right, switch the font.
That is the thing, I would add the spaces once I know when the word is being returned to the next line and I would add spaces for a calabri font... not the other way around...

I wouldnt align to the crap fonts.  I would technically just use the crap fonts to figure out when it crosses the textbox width and add spaces as if it was calabri and then switch the text to it....

it should work.. no idea...
What I'm saying is that the word being returned to the next line will be different when you switch fonts.
Here's a visual:
User generated imageCan you see that the words that get wrapped around are different in the above?
I agree with you but if it could be done as mentioned no one will care/notice if there is a space/gap in the second example if the left is aligned.  The eye trusts that if there is a space it is there for a reason.... sure in this another word could have fit but in reality no one will think anything of it.  Worst case scenario a longer word created a massive gap... in this case you would word smith things till it visually worked.  

Anyway, I know it isnt perfect.  The thing is it works in the 80/20 principle and you can work around the 20...
I'm not sure you understand what I'm getting at.  If you use the sentence with the fixed fonts to figure out that you need to add spaces before the words, "once", "line", and "other" then those spaces will now be in the wrong place when you change your fonts.

Here's what I mean.  I added spaces before the words once, line, and other.  Look at the words in red.  Do you see how your spaces are not where you want them to be when you switch to a proportional font?
User generated image
Yep, makes sense...  This is depressing... my assumption was that only one word max would be impacted not three or four...  yeah, it doesn't work... more, when the text would be wrapped it would be picking up a word with no implied spacing so it would go back underneath the bullet point...

Any ideas?  I get this isn't a report writer application but I never guessed it would be this difficult... I've gotten around many a road block on this journey...


You are a good teacher btw...
Well I tried using CSS style formatting in the HTML tags of the rich textbox but it doesn't recognize CSS so throw that idea out the window.

I also tried using a Web Browser control (this can take CSS formatting) and it looked promising because it was working in a form but when I tried it on a report, the control wouldn't respond.  I also tried adding a form as a subform in the report but that had the same problem.  I thought then that you could probably make a form that looks like a report and print it but found out that the web browser control doesn't print when you print the form.

The only other idea I have is to convert the whole report to HTML, add CSS formatting, and then view it in a browser and print it from there.  I  should add that as #4 to the workarounds I listed in my first post.  Disadvantage: it's entails quite a bit of work.
Just an aside...  
I just reread my earlier posts and noticed that the autocorrect on this site kept changing the spelling of Hanging Indents to Hanging Intents.  I just corrected them.
:-)