gi*********@gmail.com wrote in news:1155124668.427182.113590
@m79g2000cwm.googlegroups.com:
sorry if i wasn't clear on what i was trying to do. I want to run
through an entire list in a table and remove the track number. Not all
of them have track numbers so i also want to test to see if the track
number is there. THe track number will always consist of two digits
followed by a space. This is the section of text i want to remove.
I tried to post an answer in Google Grooups a few minutes ago but it
seems to be caught in an infinite loop somewhere in the ether.
So I'll try again.
Before you try anything, please, make a safety copy of your table/data.
1. Cut and paste these two proceudres into a Standard Module:
Public Function WithoutTrackNumber( _
ByVal SongTitle) As String
WithoutTrackNumber = Nz(SongTitle, "")
While IsNumeric(Mid$(WithoutTrackNumber, 1, 1))
WithoutTrackNumber = Mid$(WithoutTrackNumber, 2)
Wend
WithoutTrackNumber = Trim(WithoutTrackNumber)
End Function
Private Sub ScratchtheTrackNumbers()
CurrentDb().Execute _
"UPDATE TableSongTitles " _
& "SET SongTitle = " _
& "WithoutTrackNumber([SongTitle])"
End Sub
Change the table and field names in the second procedure to match your
table and field names. Don't change anything in the fist procedure.
Save the module.
Run the second procedure. Just in case you don't know how to do this,
here is what works for me.
I make sure the cursor is in the procedure I want to run, in this case
the Private Sub. Then I click on the Green Arrow in theStandard Toolbar
at the top. Provided the Procedure has no required parameters it should
run.
*******
Don't forget:
Before you try anything, please, make a safety copy of your table/data.
*******
But if you are doing this every day for a year you may wish to discard
the Private sub, cut and paste the first procedure (the Public Function)
into as Standard Module and save the module, and paste this SQL string
into a query in SQL view in the Query Builder (and save it) so that you
can just run it. Of course, as before you would have to change the table
and file names to match yours.
UPDATE TableSongTitles SET SongTitle = WithoutTrackNumber([SongTitle])
*******
Did I mention?
Before you try anything, please, make a safety copy of your table/data.
--
Lyle Fairfield