Spinning through a record set to remove last character

BukHix

Registered User.
Local time
, 21:55
Joined
Feb 21, 2002
Messages
379
I am trying to spin through a recordset removing the last character from each text value. The values are all -

Here is what I have so far but it's not working. Can somebody show me where I went wrong or point me to a better way?

Code:
    Dim objDB As Database
    Dim objRS As Recordset
    Dim TempString As String
    Dim ctr As Integer
    Set objDB = CurrentDb()
    Set objRS = objDB.OpenRecordset("bJCJP", dbOpenDynaset)
    
    While Not objRS.EOF
        TempString = ""
        For ctr = 1 To Len(objRS![Phase])
            TempString = _
                TempString & _
                Mid(objRS![Phase], ctr, 1, Len(objRS![Phase]) - 1)
        Next
    With objRS
        .edit
        ![Phase] = TempString
        .Update
        .MoveNext
    End With
    Wend

It has been so long since I coded in Access that this it is like I am starting all over again with VBA.
 
Buck,

Try something like this:
NewString = Left$(OldString, Len(OldString) - 1)

That will move all except the last character of OldString to NewString.

RichM
 
Thanks Rich. I was just told that removing the last character is not going to work. I need to remove the 9th character only.
 
How about:

NewString = Left(OldString,8) & Right(OldString,Len(OldString)-9)

Do you need to code this? Couldn't it be done with an Update query?
 
Do you need to code this? Couldn't it be done with an Update query?
Hey why do things the easy way when I can make them so darn complicated I can't finish my project on time. ;)

Thanks an update query was much simpler and cleaner.
 

Users who are viewing this thread

Back
Top Bottom