Add text to Memo field

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

Hi All,

I have 2 check boxes. If you check the box the on lick event adds text to a
memo field.

This issue is the last box checked text overrights the first. How would I add
the additional text without removing the first?

If me.ckbox1 = -1 then
me.memo1 = "TEXT 1"
end if

If me.ckbox2 = -1 then
me.memo1 = "TEXT 2"
end if
 
M

mattc66 via AccessMonster.com

That worked great. One more question if the user unchecks the box is there a
way to find and remove the text from the memo box?
[quoted text clipped - 11 lines]
me.memo1 = "TEXT 2"
end if

I'll assume you would like at least one space between the old and the
new data.

If me.ckbox1 = -1 then
me.memo1 = Me.memo & " " & "TEXT 1"
end if

Here I'll assme a new line between the old and new data.

If me.ckbox2 = -1 then
me.memo1 = Me.memo & vbNewLine & "TEXT 2"
end if

Take your pick.
 
F

fredg

Hi All,

I have 2 check boxes. If you check the box the on lick event adds text to a
memo field.

This issue is the last box checked text overrights the first. How would I add
the additional text without removing the first?

If me.ckbox1 = -1 then
me.memo1 = "TEXT 1"
end if

If me.ckbox2 = -1 then
me.memo1 = "TEXT 2"
end if

I'll assume you would like at least one space between the old and the
new data.

If me.ckbox1 = -1 then
me.memo1 = Me.memo & " " & "TEXT 1"
end if

Here I'll assme a new line between the old and new data.

If me.ckbox2 = -1 then
me.memo1 = Me.memo & vbNewLine & "TEXT 2"
end if

Take your pick.
 
A

Anthos

I would do it like this.

Add this to each of the check box's on change event's.

Private Sub ckbox1_Click()
If Me.ckbox1 = -1 Then
Me.memo1 = Me.memo1 & " " & "TEXT 1"
Else
Me.memo1 = Left(Me.memo1.Value, (Len(Me.memo1.Value) - Len("TEXT
1")))
End If
End Sub

this would work if the "TEXT 1" was at the end of the memo field.
If the "TEXT 1" was at the begining, you would use the RIGHT function
isntead of the left.

Private Sub ckbox1_Click()
If Me.ckbox1 = -1 Then
Me.memo1 = "TEXT 1" & " " & Me.memo1
Else
Me.memo1 = Right(Me.memo1.Value, (Len(Me.memo1.Value) - Len("TEXT
1")))
End If
End Sub

Hope that helps.


Regards
Anthony
 
M

missinglinq via AccessMonster.com

And if TEXT1 is in the middle of the field?

Me.Memo1 = Replace(Me.Memo1, Me.TEXT1, "")

Actually, I think that would work regardless of where it is in the string.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top