VB Code for a Memo Field wanted

B

bobdydd

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
 
W

Wayne-I-M

Up to you I would not bother with doing it in a form - if you REALLY want to
get rid of them all just use

UPDATE TableName SET TableName.FieldName = Replace(FieldName,"*","");
or
UPDATE TableName SET TableName.FieldName = Replace(FieldName,"*"," ");

Note the space in the second example - you can add anything you like here if
you don't want a space

this will get rid of all the * in the field
BUT make a back up of your database 1st ??
 
F

fredg

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

So you don't want Access do this for all records at one go, but you
want to do it one record at a time?

It looks as though there is an asterisk and space to be removed.

Code a command button Click event:
If Left(Me.[txtDescription],2) = "* " Then
Me.[txtDescription] = Mid([txtDescription],3)
End If
 
J

John W. Vinson

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!
 
P

put_upon

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
 
D

Douglas J. Steele

To remove the leading space, try

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