Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    117

    Unanswered: Help me in this coding

    Hello sir,
    Help me in this coding
    My recordset contains 11-2, 5-2, 5, 6 datas in no1 field
    I used the below coding to search and replace it with but not working properly.


    Private Sub Command1_Click()
    rs.Open "check1", db, 3, 2

    Dim TestString As String
    TestString = rs.Fields("no1")


    Dim aString As String

    aString = Replace(TestString, "*-*", "*/*")
    MsgBox aString

    End Sub

    The output i got is only 11-2

    Thank you sir.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Is the data "11-2, 5-2, 5, 6 " on separate "rows" within the table?

    I'm going to assume so, in which case try this.
    Code:
    rs.Open "check1", db, 3, 2
    
    Dim TestString As String
    
        TestString = ""
    
    Do While Not rs.EOF
    
        TestString = TestString & rs.Fields("no1")
        rs.MoveNext
    
    Loop
    
    rs.Close
    
    MsgBox Replace(TextString, "-", "/")
    Note that this code is written from memory with no testing
    George
    Home | Blog

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    aString = Replace(TestString, "*-*", "*/*")
    isnt the same as

    aString = Replace(TestString, "-", "/")

    in the former you have told Access to look for *-* and replace it, if found, with */"

    whereas
    aString = Replace(TestString, "-", "/")
    will replace any ocurance of "-" with "/"

    is it to late toask why you have thsi problem with your data
    why you have fractions, why you have hyphenated values
    why you are stroing what ostensibly are numeric values in string / text columns
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •