PDA

View Full Version : Solved: Add to existing comments via Userform



simora
12-27-2009, 11:04 PM
In Textbox 6 of my Excel Userform, I want to enter comments and enter those comments in Column FU.
The Row# depends on the Agent selected in ComboBox 1 = .rsRow
How do I show any comments that are already enterred from a previous encounter in Textbox6 when I start the UserForm, and allow any additional comments to be added to the existing comments in Column FU ( Column 175) when additional data is entered in Textbox6.
I can currently post data to the correct location, but cant add to existing comments or show what's already there.
This code correctly post original comments.



If TextBox6.Value <> "" Then
Cells(rsRow, 175).AddComment
Cells(rsRow, 175.Comment.Visible = False
Cells(rsRow, 175).Comment.Text Text:=strTime & ":" & Chr(10) &_ strDate & Chr(10) & "Today's Comments " & "" & TextBox6.Value
Cells(rsRow, 175).Comment.Shape.TextFrame.AutoSize = True

End If


Any suggestions and help appreciated.
Thanks

mikerickson
12-28-2009, 01:31 AM
If you run this code shortly after rsRow is determined, it will put the exisisting comment in textBox6, where the user can add to or edit it.

UserForm1.TextBox6.Value = vbNullString
On Error Resume Next
UserForm1.TextBox6.Value = Cells(rsRow, 175).Comment.Text
On Error GoTo 0

simora
12-28-2009, 02:11 PM
Thanks mikerickson :

Your code does not let me add or edit existing comments.
There's some code here at vbaexpress /kb/getarticle.php?kb_id=89
but I'm having a problem converting it right now.

mikerickson
12-29-2009, 07:25 AM
No, my code doesn't add or edit comments, the code in the OP does that.

My code puts the text from a comment into the textbox, where the user can edit it, and when done, press a button to call the code in the OP.

alternatly,


The OP code could be used in the Textbox's Change event to alter the comment as the user types in the TextBox.

simora
12-29-2009, 08:19 PM
mikerickson:
I redid the whole thing by adding a new comment to old comment in a crude way.
If you dont mind, I'm interested to see how your solution using the Textbox's Change event to alter the comment as the user types in the TextBox would work.
Thanks

mikerickson
12-29-2009, 10:20 PM
The attached has an example.

simora
12-29-2009, 11:41 PM
mikerickson (http://www.vbaexpress.com/forum/member.php?u=10706) vbmenu_register("postmenu_202501", true);

Thanks a Million.