Can anyone help me with what I suspect is a very simple problem...as you'll see, I am very much a novice...?
I have a command button on my form (FormCases1). Also on the form is a memo field (TCCaseDetails). What I want to happen on button press is for the UserName and current date/time to appear on the next free line of the memo field, then for the cursor to position itself one character width to the right of this point for the user to begin typing notes. On searching the help file it appears that the AppendChunk function is the best way of doing this and I have had a go at some code (see below). The problems are:
1: On pressing the button, the information appends to the first record in the set, not the current record, which is what I want.
2: I can't work out how to position the cursor once the operation has completed.
Here's the code, if anyone can come up with the necessary changes/additions, I'll be very grateful.
Sub CasesMemo()
Dim dbs As Database
Dim rst As Recordset
Dim fldNotes As Field
Dim lngSize As Long
Dim strChunk As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("QueryIntExtCases"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Set fldNotes = rst!TCCaseDetails
If IsNull(fldNotes.Value) Then
strChunk = CurrentUser & " " & Now
With rst
.Edit
!TCCaseDetails = strChunk
.Update
End With
Else
lngSize = Len(fldNotes)
strChunk = fldNotes.GetChunk(1, lngSize)
strChunk = strChunk & " " & CurrentUser & " " & Now
With rst
.Edit
!TCCaseDetails.AppendChunk strChunk
.Update
End With
End If
End Sub
Thanks
Chris
I have a command button on my form (FormCases1). Also on the form is a memo field (TCCaseDetails). What I want to happen on button press is for the UserName and current date/time to appear on the next free line of the memo field, then for the cursor to position itself one character width to the right of this point for the user to begin typing notes. On searching the help file it appears that the AppendChunk function is the best way of doing this and I have had a go at some code (see below). The problems are:
1: On pressing the button, the information appends to the first record in the set, not the current record, which is what I want.
2: I can't work out how to position the cursor once the operation has completed.
Here's the code, if anyone can come up with the necessary changes/additions, I'll be very grateful.
Sub CasesMemo()
Dim dbs As Database
Dim rst As Recordset
Dim fldNotes As Field
Dim lngSize As Long
Dim strChunk As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("QueryIntExtCases"
Set fldNotes = rst!TCCaseDetails
If IsNull(fldNotes.Value) Then
strChunk = CurrentUser & " " & Now
With rst
.Edit
!TCCaseDetails = strChunk
.Update
End With
Else
lngSize = Len(fldNotes)
strChunk = fldNotes.GetChunk(1, lngSize)
strChunk = strChunk & " " & CurrentUser & " " & Now
With rst
.Edit
!TCCaseDetails.AppendChunk strChunk
.Update
End With
End If
End Sub
Thanks
Chris