Solved Text manipulation

ClaraBarton

Registered User.
Local time
Today, 07:50
Joined
Oct 14, 2019
Messages
674
I have a field with a date that when I click a button, gets added to a notes box. I would like for the notes that are already in the box to move down and place the date at the beginning with with the cursor after it for adding more notes. Like so:
*11/13/21
*11/12/21 spoke with Arnold
*11/13/21 spoke with Arnold again
*11/10/21 No answer
I'm using:
Code:
Me.Parent.CNotes = vbNewLine & S & vbNewLine & CN
Me.Parent.CNotes.SetFocus
Me.Parent.CNotes.SelStart = 10
Where S = the date and CN = the notes already in the field.
If I've placed any info after the date or even just a space, it works fine.
If only the date is there and I add a new date it will not move down and start a new line.
Is there a better way of doing this?
 
Is there a better way of doing this?

Yes with a notes table. Not only are you trying to jam 2 pieces of data into 1 text field, you are trying to jam multiple records of 2 pieces of data into 1 text field. And you want to maintain order on that data. This screams for a new table.
 
A notes table is a good idea. You may try
Me.parent.cnotes = CN & vbcrlf & me.parent.notes
 
does the same thing... will not move down unless there's data after previous date.
Looks like this:
*11/21/2021| *11/22/2021| *11/23/2021|
*11/12/21| spoke with Arnold
*11/13/21| spoke with Arnold again
*11/10/21| No answer
 
It works for me fine. I cannot even get your results by trying. Can you post an example?
 
1637697236046.png

Code:
Private Sub btnVM_Click()
Dim S As String
Dim CN As String
CN = Me.Parent.CNotes
Dim Symbol As String
Symbol = Chr(42)
Dim CD As Date
CD = Nz(Me.VMDate, 0)

If CD = 0 Then
        Exit Sub
    Else: S = Symbol & CD & Chr(124)
        If IsNull(CN) Then
            CN = S
        Else: Me.Parent.CNotes = vbNewLine & S & vbCrLf & CN
        End If
    End If
    
Forms![frmDetail].AddToNotes
End Sub

Public Sub AddToNotes()
    Me!CNotes.SetFocus
    Me.CNotes.SelStart = 13

End Sub
 
I basically copied your code and get no issue. Not sure what the problem is.
 

Attachments

is your notes field set to rich text by any chance?

If so vbcrlf/vbnewline etc won't work, you need to use '<div>' and '</div>'
 
Huh! Would it have anything to do with mine being formatted as Rich Text?
 
Probably. Let me look if I can replicate.
 
See if this works. I added the HTML tag
Me.txtNote = S & "<div>&nbsp;" & CN
 
you only need to add "<br>" to your memo.
 

Attachments

if you are not using the the richtext features, just change the field (and control) to plain text
 

Users who are viewing this thread

Back
Top Bottom