removing certain text from a string in a text box (find & replace?)

  • Thread starter Thread starter Tim Marsh
  • Start date Start date
T

Tim Marsh

hi, i have a simple database, one of its forms has textboxes for collecting
information. One of the textboxes has text from emails, which have the '> '
markers indicating a replied-to message.

i'm new to Access and don't really understand how to reference objects in
VBA; can someone tell me what code i would need to assign to a button on the
form to access the textbox (called 'Code') to remove all occurences of the
'> ' which occur at the start of a new line (i presume it would be some kind
of find & replace routine).

Thanks for any help you can provide,

Tim
 
Tim:

Put the following in the button's Click event procedure:

Me.Code = Replace(Me.Code, vbNewLine & ">", vbNewLine)

If Left(Me.Code, 1) = ">" Then
Me.Code = Mid(Me.Code, 2)
End If

The first replaces a carriage return/line feed (which the vbNewLine constant
represents) followed by the > character with just the carriage return/line
feed. The Replace function does this for all occurrences of the substring.
Then the If…End If construct removes the > character if there is one at the
start of the first line, which the Replace function will have left because
its not preceded by a carriage return/line feed.

Ken Sheridan
Stafford, England
 

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

Back
Top