Solved Text manipulation (1 Viewer)

ClaraBarton

Registered User.
Local time
Yesterday, 18:52
Joined
Oct 14, 2019
Messages
461
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?
 

plog

Banishment Pending
Local time
Yesterday, 20:52
Joined
May 11, 2011
Messages
11,645
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.
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 21:52
Joined
May 21, 2018
Messages
8,527
A notes table is a good idea. You may try
Me.parent.cnotes = CN & vbcrlf & me.parent.notes
 

ClaraBarton

Registered User.
Local time
Yesterday, 18:52
Joined
Oct 14, 2019
Messages
461
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
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 21:52
Joined
May 21, 2018
Messages
8,527
It works for me fine. I cannot even get your results by trying. Can you post an example?
 

ClaraBarton

Registered User.
Local time
Yesterday, 18:52
Joined
Oct 14, 2019
Messages
461
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
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 21:52
Joined
May 21, 2018
Messages
8,527
I basically copied your code and get no issue. Not sure what the problem is.
 

Attachments

  • Notes.accdb
    576 KB · Views: 271

CJ_London

Super Moderator
Staff member
Local time
Today, 02:52
Joined
Feb 19, 2013
Messages
16,607
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>'
 

ClaraBarton

Registered User.
Local time
Yesterday, 18:52
Joined
Oct 14, 2019
Messages
461
Huh! Would it have anything to do with mine being formatted as Rich Text?
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 21:52
Joined
May 21, 2018
Messages
8,527
Probably. Let me look if I can replicate.
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 21:52
Joined
May 21, 2018
Messages
8,527
See if this works. I added the HTML tag
Me.txtNote = S & "<div>&nbsp;" & CN
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:52
Joined
May 7, 2009
Messages
19,231
you only need to add "<br>" to your memo.
 

Attachments

  • nota.accdb
    576 KB · Views: 328

CJ_London

Super Moderator
Staff member
Local time
Today, 02:52
Joined
Feb 19, 2013
Messages
16,607
if you are not using the the richtext features, just change the field (and control) to plain text
 

Users who are viewing this thread

Top Bottom