Hi thanks for reply, I just tried that and it does the same - both phrases on the same line in the RTF memo field

Ive used vbnewline in a msgbox before and works fine, but it stumped me as to why its not working in memo field.

once i get this working then I will use it to drop new lines into the memo field on afterupdate from a combo.

heres my test code:

Private Sub cmdNewlines_Click()
Me.DocsNeededToProceed = "First line" & vbNewLine & "Second Line"

End Sub

****
thanks for your help

Ohhh, I got it now, what you want. It's really easy, so this is how it should be:

Private Sub YourButton_Click()
Memo.Value = Memo.Value & vbNewLine
End Sub

Hope it helps. Dan08

Hi Dan08,

yes many thanks, that line of code works , it appends "new text ...etc" to the current contents of the memo. however does not create a new line every time cmd is actioned.

So for eg from my combo box user chooses Item1, then after that using same combo chooses item2 .... etc .item3 ... item4

then memo field would be:
Item1
Item2
Item3
Item4

Im curious also as to not needing me. reference ?? I have been always coding current fields as me.field

many thanks!
Jon

So you also have combos? and when you chose one of them it print to the text field, is that right? I think this will work for you:

Private Sub Combo5_Click()
If Combo5 = "first" Then
    If Text0.Value = "" Then
        Text0.Value = "first"
    Else
        Text0.Value = Text0.Value & vbNewLine & "first"
    End If
ElseIf Combo5 = "second" Then
    If Text0.Value = "" Then
        Text0.Value = "second"
    Else
        Text0.Value = Text0.Value & vbNewLine & "second"
    End If
Else
    If Text0.Value = "" Then
        Text0.Value = "third"
    Else
        Text0.Value = Text0.Value & vbNewLine & "third"
    End If
End If
End Sub

I think that will work for you.

Is it working now? Or did you find another way of doing it?

hi there,
no I cant figure it out, I tried a few things but it still only appends txt string on the same line each time the procedure runs - like the image capture . it should work, but does not.
any ideas? so does it work fine on your machine ? are you using Plain Text Memo or RTF ? if that makes a difference?

Well it does work on mine, but anyway I have been doing some more tests, and well... try this: Create a table, in it add a field, and name it "Memo", for data type use "Memo", now create a form, the control source of the form will be over the table you just created and now in your form add a Text Box, name it Memo and also add a ComboBox and name it Combo, use the wizard for the combo, for testing purposes, select "I will type in the values that I want", then press next, then under "col1" add, "first", and then "second" and then "third", then press Finish. Ok, almost done, now go to the properties of the Combo and the event tab, now open up "Microsoft Visual Basics", which is named "Code" in the Access GUI, in there, copy and paste the following:

Private Sub Combo_Click()
If Combo = "first" Then
    If Memo.Value = "" Then
        Memo.Value = "first"
    Else
        Memo.Value = Memo.Value & vbNewLine & "first"
    End If
ElseIf Combo = "second" Then
    If Memo.Value = "" Then
        Memo.Value = "second"
    Else
        Memo.Value = Memo.Value & vbNewLine & "second"
    End If
Else
    If Memo.Value = "" Then
        Memo.Value = "third"
    Else
        Memo.Value = Memo.Value & vbNewLine & "third"
    End If
End If
End Sub

Ok, that works perfectly for me, now if it doesnt work for you, you may want to substitute "vbNewLine" for "vbCrlF", which also works for me. If this doesnt work then I dont know what else can I do for you. Well just one more thing, what do you mean by "are you using Plain Text Memo or RTF?" ?, Yes, and thats all. Dan08

oh just seen ur response.. I'll set this up in a min to try thanks

Plain Text, or RTF memo ; I mean -
when you add a memo field to table in the properties you can set its format to either plain text, or Rich Text Format - so you can use extended formats in the field on a form - bullets, fonts, colour etc etc. and I have mine set to RTF
So i just wondered if that seting made any difference to this working or not

Have you tried it? Is it working?

HI, yes works fine as plain text memo, but not as RTF memo
[IMG]http://i40.tinypic.com/52xsfb.png[/IMG]
my memo fields have to be RFT, as such it places each word appending on the same line as per the img above. it must be down to some quirky think with it not liking RTF. Yet many thanks for all your help for the code that works on plain txt

Can't you just use Plain Text Memo? Does it have to be RTF memo?

there may be some workaround, like if I make a command to copy the plain txt memo into a RTF memo and then manually format it with bullets. as this memo will be dumped into a report so its idea to have it formatted RTF so casn use bullets and font weights. but idealy I wanted to be able to drop lines of txt into the RTF memo already with bullets.

Sorry I have no idea how to do it, and by the way no problem. I help people for fun :)

Just to recap for anyone reading this ... above code by Dan08 does the trick of inserting new line into memo field from a cmbo list. there seems to be a bit of an unknown as to why this vbnewline does not work with memo fields whose text property is set to Rich Text Format.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.