Problem with adding comments to a text box, and having the text box keep updating and NOT deleting the text that currently is in the text box.

database_coder

New Member
Joined
Feb 6, 2014
Messages
35
Hi all, I have a form that has three fields (1. Comments (TEXT), 2. Legacy_Comments (TEXT), 3, Comment date (DATE))

Now my users need to keep adding comments to the comment text box, and when they do it automatically adds the date they entered the comment in the Comment date box. Now my problem is that since they keep adding comments to the comment box, I need to keep track of these comments in the Legacy_Comments (Text box).

For example, the First time a user enters a comment into the (1) comment text box it auto populates the date in the comment date box, and then adds the comment and date to the Legacy_Comment box. the end result is (comment,4/3/2014;) now lets say a user needs to add a comment to the comments box tomorrow - I want the legacy_Comment box to then read (comment, 4/3/2014; comment2, 4/4/2014, ...., comment(n),date(n)) OR it can be vice-verse, because I just need to keep track of the comments, I am not worried if the new comments are before or after older (yesterdays / the day before yesterdays comments)

How can I write a
<acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: rgb(0, 0, 0); cursor: help; color: rgb(51, 51, 51); background-color: rgb(250, 250, 250);">VBA</acronym> code that will always add the new comment to the legacy_comment field, without deleting the comments that were entered previously?

So far I have tried, but no success.

Code:
If isnull(me.comment.value) Then   
     Exit Sub
ElseIf me.comment.value = true Then 
     me.comment_date.value = date   
     me.legacy_comment.value = me.comment.value & "," & me.comment_date.value & ";" 
     me.legacy_comment.value = me.legacy_comment.value & "," & me.comment_date.value & ";"

It adds the comment only the first time, but it does not concatenate the string from yesterday to the string to today. I do not care which order the comments are, meaning if I added a comment today it can be before OR after the comment from yesterday.

Could anyone help me solve this problem? Or, has anyone else encountered this problem? If so, how did you get around to solving it?
 
Last edited:

L. Howard

Well-known Member
Joined
Oct 16, 2012
Messages
4,514
Perhaps a version of something like this. (This is a snippet from code that populates a TextBox)

If you wanted the comments each on it's own line then where you see the [ = " " & ] you could put [ vbCr & ].

Where MyStringVariable is the comment.

Regards,
Howard

Code:
    With ActiveSheet.TextBox1
      If Len(.Text) > 0 Then MyStringVariable = " " & MyStringVariable
      .Text = .Text & MyStringVariable
    End With
 

Forum statistics

Threads
1,082,323
Messages
5,364,579
Members
400,809
Latest member
formulasataglance

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top