Full Version: insert text at beginng if a line not at end a existing text
UtterAccess Forums > Microsoft® Access > Access Forms
punkin
Hi,
I have added this code to a field so other user know who added the comments. The code works fine except I would like to have the text inserted in a new line not at the end of an existing comment in the field.
urrent problem ie .. ( comment added by prrgnt 01/01/2008) >> case re-allocated to Peter - (comments added by prdgrt) >> sent letter to agent reguesting more information.
Ideally I would like the comments to look like this;
(comments added by prrgnt 01/01/2008) - case re-allocated to peter
(comments added by prdgrt 02/01/2008) - sent letter to agent requesting more information.
Is there any way i can make this happen?.
This is the code I am using
Private Sub txtCommentsAdd_AfterUpdate()
If MsgBox(" Are the comments you entered correct?", vbYesNo) = vbYes Then
Me.txtComments = Me.txtComments & " - ( Comment by " & fSystemUserName & " of " & Date & " >> ) - " & Me.txtCommentsAdd 'adds and new comments"
Me.txtCommentsAdd = Null 'Clears add box
Me.Refresh 'refreshes the form
Me.txtCommentsAdd.Requery
Else
Me.txtCommentsAdd.SetFocus
End If
End Sub
Private Sub txtCommentsAdd_Change()
Const intX As Integer = 255
If Len(Me.txtCommentsAdd.Text) >= intX Then
Me.txtCommentsAdd.Text = Left(Me.txtCommentsAdd.Text, intX)
Me.txtCommentsAdd.SelStart = Len(Me.txtCommentsAdd.Text)
End If
Me.txtRemain = intX - Len(Me.txtCommentsAdd.Text)
End Sub
petesmall
Hi,

Try this in Private Sub txtCommentsAdd_AfterUpdate()
CODE
  
If MsgBox(" Are the comments you entered correct?", vbYesNo) = vbYes Then
Me.txtComments = Me.txtComments & iif(len(Me.txtComments)=0,"",vbCrLf) & _
  " - ( Comment by " & fSystemUserName & " of " & Date & " >> ) - " & _
  Me.txtCommentsAdd 'adds and new comments


This should put a carriage return and linefeed into the comment.

Best,
Pete


Edited to prevent page width expansion.

Edited by: VanThienDinh on Thu Aug 21 22:48:04 EDT 2008.
petesmall
Hi Van,
Thanks for the edit!
Best,
Pete
punkin
Thank you for that..works perfectly.
Sorry that I didnt reply earlier.. been sick with the flu
petesmall
You are welcome! Looks like an interesting project.
est,
Pete
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.