Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Numeric to Alpha (A2K)

    Seemingly simple as usual. Want to create an Alphanumeric field from an Autonumber field. I tried NewAlphaField: str([AutoFieldName]). If the AutoFieldName was a numeric 4, I get back an alphanumeric field with a 4 OK, but an embedded space in front of the 4. From whence came it? Appreciate any suggestions. Need to use this field for comparison to another alphanumeric field, but can't do it because of the embedded space.
    Cheers,
    Andy

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

    Re: Numeric to Alpha (A2K)

    The space prefix is a "feature" of the Str function - for positive numbers and zero, a space is prefixed, for negative numbers a minus sign. In the olden days of fixed-width fonts, this would ensure that for example 37 and -37 lined up.
    If you already have a text field, you can update it simply to [AutoFieldName]. Access will take care of the conversion from long integer to string, without prefixing a space...

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Numeric to Alpha (A2K)

    Hans,
    Thanks as always for your quick and accurate reply. What I've done is probably not considered cricket, but in the Before Update event on my form I put in:
    [NewAlphaField]=[AutoNumberField] which writes back into the table the alphanumeric version of the autonumber without a leading space. Not neat, but it works. Thanks again,
    Andy
    Cheers,
    Andy

Posting Permissions

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