Results 1 to 5 of 5

Thread: Replace function question with syntax

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2003
    Posts
    93

    Replace function question with syntax

    The line below currently works just fine. The * on either end are there as the data in the string is a barcode.

    "*" + Trim({CusCushionInv.BaseModel} + "*")

    I now need to program for the possibility of a space in that string as it can not be output to a barcode with the space. What I want to do is have a replace function that looks for a space and replaces it with an underscore _ character. This is what I've come up with but I have something wrong as I'm getting an error: "Too many arguments have been given to this function."

    Replace ("*" + Trim(({CusCushionInv.BaseModel} + "*"), " ", "_"))

    Can anyone see what my problem might be? I'm thinking that it's a syntax problem but I'm not sure.

    Thanks

  2. #2
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question

    I have no idea what your CusCushionInv.BaseModel item is, but normally if you want to use the replace function, you'd do it like this:

    VB Code:
    1. sMySample = sCompanyName.Replace(" ", "_")
    or
    VB Code:
    1. sSQL = "SELECT * FROM tbl_Company WHERE CompanyName = '" & sCompanyName.Replace(" ", "_") & "';"
    ~Peter


  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2003
    Posts
    93
    Well, CusCushionInv.BaseModel is the string. This is from a function within Crystal Reports & like I said I need to incorporate the "*" part on each end.

  4. #4
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question

    So just add the star on.
    VB Code:
    1. sMySample = "*" & sCompanyName.Replace(" ", "_") & "*"
    Is that not what you want to do?

    Or maybe you want:
    VB Code:
    1. "*" + Replace(Trim({CusCushionInv.BaseModel}), " ", "_") + "*"
    (i think you had too many brackets?)
    ~Peter


  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2003
    Posts
    93
    MRGTI,

    That was it. I had the first "*" on the wrong side of the Replace. When I checked the syntax in crystal it cam back without any errors. I'll try printing the barcodes to make sure it works correctly.

    Thanks!

Posting Permissions

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



Click Here to Expand Forum to Full Width