carriage return not working or missing (1 Viewer)

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 09:05
Joined
Nov 8, 2005
Messages
3,296
Hi Guys
I have a tick box that once ticked goes and looks up data and then adds it to a memo field (works ok.)
but I need to add a carriage return for when I add the next one
(I have a list of possible data that I may need and this is in a continuous form layout ) as you can see I think i have tried variosu methods but each time i click the button it data sits next to and not below the last data retrieved .
what/where have i gone wrong
G:banghead:

Private Sub REquiredY_AfterUpdate()

Dim EndTxt As String

If REquiredY = True Then

EndTxt = DLookup("wording", "wording", "[endorsementid]=" & Me.endorsementid)

Set db = CurrentDb
Set rs = db.OpenRecordset("Generaltbl", dbOpenDynaset)
rs.FindFirst "[GenReferenceNo]=" & Me.GenReferenceNo

Dim EndorsementAdd1 As String

rs.Edit

EndorsementAdd1 = rs.Endorsements & EndTxt & vbCrLf & vbCr & vbNewLine & vbLf

rs.Endorsements = vbCrLf & vbCr & vbNewLine & vbLf & EndorsementAdd1



rs.Update

rs.Close
End If






End Sub
 

isladogs

MVP / VIP
Local time
Today, 17:05
Joined
Jan 14, 2017
Messages
18,209
Hi Gary
You posted to a moderated area (Code Repository) which is not intended for questions. I've moved it to the modules and VBA section and approved the post.

You can add a new line using vbCrLf or vbNewLine. You don't need all the items you've listed.

In your DLookup do you really have a field wording in a table of exactly the same name? Bad idea.

Try rs.Endorsements =rs.Endorsements & vbCrLf & EndTxt
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 09:05
Joined
Oct 29, 2018
Messages
21,449
Hi. Do you really have to use a recordset object? Also, did you really try all those options at the same time? If the Memo field is displayed on the same form, could you simply try the following and let us know if it doesn't help?
Code:
Me.MemoField = Me.MemoField & vbNewLine & "Testing..."
 

Micron

AWF VIP
Local time
Today, 12:05
Joined
Oct 20, 2018
Messages
3,478
I'd say step back and describe what you have and what you need to happen, not what doesn't work.
- A DLookup on a memo (long text) field is asking for issues IIRC.
- a memo field is for characters longer than 255 - OK there - but you probably shouldn't be doing to it what you're doing

Oh... and please use code tags (# on menu bar) with indentation for anything more than a few lines.
 
Last edited:

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 09:05
Joined
Nov 8, 2005
Messages
3,296
Hi. Do you really have to use a recordset object? Also, did you really try all those options at the same time? If the Memo field is displayed on the same form, could you simply try the following and let us know if it doesn't help?
Code:
Me.MemoField = Me.MemoField & vbNewLine & "Testing..."

Thanks for this and they are on different forms
(i have this where it is on the same form and this works a treat ) problem is two forms two different tables...)
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 09:05
Joined
Nov 8, 2005
Messages
3,296
resolved - not the tidiest and I am pretty sure a little bit wrong - but does the job
I added in bq and bqe (see below) to get a return line ..
THansk guys for your input

Dim EndTxt As String

If REquiredY = True Then

EndTxt = DLookup("wording", "wording", "[endorsementid]=" & Me.endorsementid)

Const bq As String = "<blockquote>"
Const bqe As String = "</blockquote>"


Set db = CurrentDb
Set rs = db.OpenRecordset("Generaltbl", dbOpenDynaset)
rs.FindFirst "[GenReferenceNo]=" & Me.GenReferenceNo

Dim EndorsementAdd1 As String

rs.Edit

EndorsementAdd1 = " " & vbq & bqe & " "



rs.Endorsements = rs.Endorsements & vbCrLf & EndorsementAdd1 & EndTxt

rs.Update

rs.Close
End If
 

bob fitz

AWF VIP
Local time
Today, 17:05
Joined
May 23, 2011
Messages
4,718
Perhaps in the "Thread Tools" dropdown located just above the first post
You can also "Thank" individual post that you fine helpful by clicking the "Thanks" button which can be found in the bottom right corner of each post.
 
Last edited:

Users who are viewing this thread

Top Bottom