dbTalk Databases Forums  

VB Code for a Memo Field wanted

comp.databases.ms-access comp.databases.ms-access


Discuss VB Code for a Memo Field wanted in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bobdydd
 
Posts: n/a

Default VB Code for a Memo Field wanted - 05-21-2009 , 01:37 PM






Hi All

I Have Memo Field (txtDescription) that

which has the following data (or similar) on 10,000 records

Some of the records have a * before each line an some don't

* 820 Watt, 230v motor
* Variable speed control with reverse action 0 to 2500rpm
* Speed limiter dial on switch ensures consistent drilling at slower
speeds
* Selector switch for rotary hammer or rotary only drilling
* Lock-on button automatically releases if power is cut
* Includes 13mm keyed chuck, depth gauge & auxiliary front handle
* Weight 2.4kgs

I would like to open the form which contains this data and be able to
click a Command Button to strip out the stars whenever I see them,
rather than remove the stars one by one. I do not want to go through
the records and have do the whole lot in one go (on the current
event??) jsut strip them out whenever I see a record that has the *'s

Thanks


Reply With Quote
  #2  
Old   
John W. Vinson
 
Posts: n/a

Default Re: VB Code for a Memo Field wanted - 05-21-2009 , 04:46 PM






On Thu, 21 May 2009 11:37:15 -0700 (PDT), bobdydd
<reallyuseful2004 (AT) yahoo (DOT) co.uk> wrote:

Quote:
Hi All

I Have Memo Field (txtDescription) that

which has the following data (or similar) on 10,000 records

Some of the records have a * before each line an some don't

* 820 Watt, 230v motor
* Variable speed control with reverse action 0 to 2500rpm
* Speed limiter dial on switch ensures consistent drilling at slower
speeds
* Selector switch for rotary hammer or rotary only drilling
* Lock-on button automatically releases if power is cut
* Includes 13mm keyed chuck, depth gauge & auxiliary front handle
* Weight 2.4kgs

I would like to open the form which contains this data and be able to
click a Command Button to strip out the stars whenever I see them,
rather than remove the stars one by one. I do not want to go through
the records and have do the whole lot in one go (on the current
event??) jsut strip them out whenever I see a record that has the *'s

Thanks
Are these multiple memo fields each with one or two lines? Or one big memo
field with multiple lines?

Do you want to remove all the asterisks in just one record? or all of the
(sub?) records on a form?

More details please!
--

John W. Vinson [MVP]


Reply With Quote
  #3  
Old   
put_upon
 
Posts: n/a

Default Re: VB Code for a Memo Field wanted - 05-22-2009 , 05:33 AM



Hi

I am using Access 2007 running on Windows XP. I am not that brave
to us Vista yet

I was able to remove all the stars in the text with the followng code
Me.txtDescription = Replace(txtDescription, "*", "")

It does not remove the leading space from each of the lines, but
as it is being pasted into Dreamweaver that does not matter as DW
remove all formatting until you apply HTML.

Thanks to everyone who helped

Regards and Thanks


Reply With Quote
  #4  
Old   
Douglas J. Steele
 
Posts: n/a

Default Re: VB Code for a Memo Field wanted - 05-22-2009 , 06:20 AM



To remove the leading space, try

Me.txtDescription = LTrim(Replace(txtDescription, "*", ""))


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"put_upon" <reallyuseful2004 (AT) yahoo (DOT) co.uk> wrote

Quote:
Hi

I am using Access 2007 running on Windows XP. I am not that brave
to us Vista yet

I was able to remove all the stars in the text with the followng code
Me.txtDescription = Replace(txtDescription, "*", "")

It does not remove the leading space from each of the lines, but
as it is being pasted into Dreamweaver that does not matter as DW
remove all formatting until you apply HTML.

Thanks to everyone who helped

Regards and Thanks




Reply With Quote
  #5  
Old   
Salad
 
Posts: n/a

Default Re: VB Code for a Memo Field wanted - 05-22-2009 , 10:00 AM



put_upon wrote:
Quote:
Hi

I am using Access 2007 running on Windows XP. I am not that brave
to us Vista yet

I was able to remove all the stars in the text with the followng code
Me.txtDescription = Replace(txtDescription, "*", "")

It does not remove the leading space from each of the lines, but
as it is being pasted into Dreamweaver that does not matter as DW
remove all formatting until you apply HTML.

Thanks to everyone who helped

Regards and Thanks

If a carrigage return/line feed is contained in the memeo lines, this
demos how to remove the leading spaces. Use one line help for keywords
you don't understand. Copy the code below into a code module and run
the demo code.

Sub ArTest()
Dim m As String
Dim sTrim As String
Dim sOrig As String

Dim i As Integer
Dim ar() As String

m = " this is line1" & vbNewLine
m = m & " this is line2" & vbNewLine
m = m & " this is line3"

'creates an array of each line using cr/ln as the delimeter
ar = Split(m, vbNewLine)

For i = LBound(ar) To UBound(ar)
'remove leading space
sTrim = sTrim & Trim(ar(i)) & vbNewLine 'removes space
'keep original
sOrig = sOrig & ar(i) & vbNewLine 'keeps orig format
Next

'display orig and then space removed
MsgBox "Original: " & vbNewLine & _
sOrig & vbNewLine & _
"Trimmed: " & vbNewLine & _
sTrim

End Sub


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.