?
Solved

Comments in a text box

Posted on 2012-09-05
19
Medium Priority
?
341 Views
Last Modified: 2012-09-06
Ok, I had a great solution for adding comments to a comments field in my database.  The code that I used is the following:

Private Sub cmdAddComments_Click()
Forms![FRM_DataObjects]![Comments]= Forms![FRM_DataObjects]![Comments] & vbCrLF & Me.txtCommentsEntry & vbCrLF & "Date/Time Posted:  " & Format$(Now(), "mm/dd/yy hh:nn:ss") & "User:   " & WhoAmI(True)

I thought  I could put the FontSize=8 since I just want the Date/Time Posted, User part of the comment line to be a 8 point and the actual comments to be at the normal size. Could someone help me?
0
Comment
Question by:lauriecking0623
  • 8
  • 6
  • 3
  • +2
19 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38369003
No can do.. a control (textbox) will only take one font size.

you can try Rich Text if you are using A2007 or A2010
see this link
http://www.techrepublic.com/blog/msoffice/how-to-work-with-rich-text-in-access-2007-and-2010/4795
0
 
LVL 2

Expert Comment

by:Benji_
ID: 38369004
Store the information in seperate fields and then set the font size when you pull the information back.
0
 

Author Comment

by:lauriecking0623
ID: 38369083
@capricorn1

I will check my field, it is a memo field but I am not sure if I have the Rich Text selected.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:lauriecking0623
ID: 38369204
@capricorn1

I have created two new fields with Rich Text format per your email. I did an update query to move the data from the old fields to the new fields and deleted the old fields.  

Now, I need to know if I put a FontSize = 8 in my code line mentioned above would change the text behind of it.

What is your thoughts?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38369293
Try something like this:
See: Query4 and Form4

I am sure you can see the syntax I used and modify it to fit your needs
SampleDB.accdb
0
 

Author Comment

by:lauriecking0623
ID: 38369346
This is won't work for me.  Let me explain how my form is setup.

I have a form with Comments field in my table.  On my form to add a comment, the user clicks on the Add Internal Comments button. I have an unbound form that has txtCommentsEntry and a save button that actually adds the text.

So that command button has a code that saves the comment (actual comment) along with on a separate line is Date/Time, User id,. I want to be able to take the code that I have mentioned above so the comments are font size of 12 and the date/time and user information is font size of 8.

Does that make sense?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38369534
<Does that make sense? >
yes and no...

My sample illustrates how to insert Line breaks and formatting the text for different sizes.
(This is the main thrust of your question.)
Does my sample illustrate this in a general sense?
Yes or No...
If No, then explain why the "Output" I present is "wrong"

I don't see a real need to "Store" the concatenated data.
(as long as it can be presented in the way you want.)

<I want to be able to take the code that I have mentioned >
Your code will not work for what you are trying to do.
If you want to use your code then it will have use HTML strings,

This is why it is always best if you post a sample file (to avoid ambiguity):

Sample database notes:
1. Back up your database(s).
2. Combine the front and back ends into one database file.
3. Remove any startup options, unless they are relevant to the issue.
4. Remove any records unless they are relevant to the issue.
5. Delete any objects that do not relate directly to the issue.
6. Remove any references to any "linked" files (files outside of the database, Images, OLE Files, ...etc)
7. Remove any references to any third party Active-x Controls (unless they are relevant to the issue)
8. Remove, obfuscate, encrypt, or otherwise disguise, any sensitive data.
9. Unhide and hidden database objects
10. Compile the code. (From the VBA code window, click: Debug-->Compile)
11. Run the compact/Repair utility.
12. Remove any Passwords and/or security.
13. If a form is involved in the issue, set the Modal and Popup properties to: No
    (Again, unless these properties are associated with the issue)
14. Post the explicit steps to replicate the issue.
15. Test the database before posting.

In other words, ...post a database that we can easily open and immediately see and/or troubleshoot the issue.
And if applicable, also include a clear graphical representation of the *Exact* results you are expecting, based on the sample data.

JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38369595
In a nutshell, the basic HTML I posted in the query (and in the Form control), wold be what you would adapt your code to.

But again, my point here is that I have demonstrated how to add line breaks and Font sizing to a string.
All you have to do is take what I did and modify it to work in your database.

Something like this perhaps...
Forms![FRM_DataObjects]![Comments]=  "<Font Size=14>" & Forms![FRM_DataObjects]![Comments] & "<br>" &  Me.txtCommentsEntry & "<br>" & "Date/Time Posted:  " & Format$(Now(), "mm/dd/yy hh:nn:ss") & "User:   " & WhoAmI(True)

...and don't forget to set the "TextFormat" property of the comments field/control to : Rich Text
0
 

Author Comment

by:lauriecking0623
ID: 38369698
@boad2000 (Jeff Coachman)

I have the fields set as Rich Text.  I tried your code but I just want to reduce the size of Date/Time Posted: mm/dd/yy hh:.nn:ss and User information to font size 8. The comments that is extracted from the txtCommentsEntry field on a separate form will have the default font size of 12.

Let me get a db ready to upload with the samples.

Thanks
Laurie
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38369737
<but I just want to reduce the size of Date/Time Posted: mm/dd/yy hh:.nn:ss and User information to font size 8.>
Again, just adapt my syntax to what you need
Something like this perhaps...

Forms![FRM_DataObjects]![Comments]=  "<Font Size=12>" & Forms![FRM_DataObjects]![Comments] & "<br>" &  Me.txtCommentsEntry & "<br>" & "Date/Time Posted:  " &  "<Font Size=8>" & Format$(Now(), "mm/dd/yy hh:nn:ss") & "User:   " &   "<Font Size=8>" & WhoAmI(True)


But again, it is not clear if you are just saying that this is not what you want, ...or if you are taking the time to actually see if you can make it work in your database.

Again, I have clearly demonstrated how to set the line breaks and set the font sizes...
0
 

Author Comment

by:lauriecking0623
ID: 38369826
@boag2000,

You have definitely helped me with the code. I understand what you are saying. You are doing what I am asking for and I have been playing with this for a  while before posting.  I will try your suggestion, if it does not work then I can post my database and show you what I would like to do.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38369877
Ok, great, ...keep me posted.

;-)

Jeff
0
 

Author Comment

by:lauriecking0623
ID: 38369989
@Jeff (boag2000)

Attached is my database to this posting. Open up the FRM_DataObjects Form, you will get a pop up message that refers to missing time, just click "Ok" then the form opens up. Click on the Comments button. The Comments form opens up, type something in it and click Save Comments.  The code is on Save Comments button OnClick of the FRM_Comments.
Database3.accdb
0
 
LVL 31

Expert Comment

by:hnasr
ID: 38370050
Did not check  database examples in previous comments. This is the job of the OP.
Here is my contribution:
To reproduce it you need
                        Memo field:
                                 name:m
                                 Format: Rich Text
                       Text Field for Comment:
                                 Name: txtm
                                 Format: Plain Text
Button click to add text in txtm size 12 and Now(), the current date time in size 8

Private Sub Command7_Click()
    Dim strComment As String
    Me!txtm.SetFocus
    strComment = Me!txtm.Text
    Me!m.SetFocus
    Me.m = Me!m & "<div>" _
                            & "<font size=3>" & strComment & "</font>" _
                            & "<font size=1>" & " " & Now() & "</font>" _
                & "</div>"
    Me.m.SelStart = Len(m)
End Sub

Open in new window

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38370452
lauriecking0623,

Did you read steps I listed for posting a sample database?
>post a database that we can easily open and immediately see and/or troubleshoot the issue.
The constant pop-up for the date is very annoying and only frustrates Experts trying to assist you.
>13. If a form is involved in the issue, set the Modal and Popup properties to: No
    (Again, unless these properties are associated with the issue)

...and this is *crucial*:
also include a clear graphical representation of the *Exact* results you are expecting, based on the sample data.
You always say/write what you want, bout this is never as clare as a image of the *exact* results you need.

In any event try something like this:
Forms![FRM_DataObjects]![Comments] = "<Font Size=5>" & Forms![FRM_DataObjects]![Comments] & "<br>" & Me.txtCommentsEntry & "<br>" & "Date/Time Posted:  " & "<Font Size=5>" & Format$(Now(), "mm/dd/yy hh:nn:ss") & "<br>" & "User:   " & "<Font Size=3>" & WhoAmI(True)

As far as I know, HTML does not accept the standard windows font sizes, so you will have to play around with the numbers.
See here for more info: http://www.w3schools.com/tags/att_font_size.asp

Again, ...This works.
All you have to do is modify it slightly for the exact output you require.

JeffCoachman
0
 
LVL 31

Accepted Solution

by:
hnasr earned 2000 total points
ID: 38370577
Modified Comments field to Rich Text.
Adopted my comment to your database.
Try!
Please do some homework to format your text.
Database4.accdb
0
 

Author Comment

by:lauriecking0623
ID: 38370629
@Jeff Coachman,

Thank you for your help. Please know that I truly appreciate your assistance on my issues. It has been a HUGE help with impressing my employer where once I finish it then we can also re-purpose it.

Let me try your recommendations in the morning. I will get back to you. Thank you again.

Laurie
0
 

Author Closing Comment

by:lauriecking0623
ID: 38372332
This worked in my database. Thank you so much!!
0
 
LVL 31

Expert Comment

by:hnasr
ID: 38372376
Welcome!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question