Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Royal Oak, Michigan, USA
    Posts
    255
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Strip Teaser (V2002)

    I cannot seem to pull together code to correctly strip leading zeroes from a string. cint( won't work because the field can be alpha-numeric. The only characters I will need to strip will be all leading zeroes.
    Thanks!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Strip Teaser (V2002)

    You can paste the following function in a standard module:

    Public Function StripLeadingZeros(ByVal aValue As Variant) As Variant
    If IsNull(aValue) Then
    StripLeadingZeros = Null
    Else
    Do While Left(aValue, 1) = "0"
    aValue = Mid(aValue, 2)
    Loop
    StripLeadingZeros = aValue
    End If
    End Function

    Use this function in a query or in the control source of a text box. For example in a calculated field in a query:

    StrippedValue: StripLeadingZeros([FieldName])

  3. #3
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Royal Oak, Michigan, USA
    Posts
    255
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Strip Teaser (V2002)

    Hans,
    You are an absolute Champ!
    Thanks!
    Andrew

Posting Permissions

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