Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2009
    Posts
    10

    Unanswered: Need to display last 4 digits of a Number in report

    I need to display the last 4 of a SSN on an access report.

    I know how to format a text string, in this case the SSN is stored as a number and formatted on the reports and forms to display any leading zeros.

    Just spent over an hour and cant find an example. I know I have seen this before.

    Please Help!

  2. #2
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    Right([SSN], 4)
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  3. #3
    Join Date
    Oct 2009
    Posts
    10
    OK, I feel really stupid!
    I had tried that and it returned an error.
    I know why now, I left the control name as "SSN" as soon as I changed it this worked.

    Thanks for making me look at it again!!

  4. #4
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    Don't worry about it! The number of times I've started infinite loops going by missing out the "MoveNext" command is just daft...
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  5. #5
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580
    "The number of times I've started infinite loops"

    Personally, If writing code for a recordset, I tend to write;

    ...blah...
    'Actions here
    rs.movenext
    loop

    rs.close
    set rs = nothing
    set qd = nothing
    set db = nothing
    ...etc...
    (or the equivalent) before any action statements within it and then go back and code the actions - if you get into this habbit, you shouldn't make the same mistake hopefully.
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  6. #6
    Join Date
    Oct 2009
    Posts
    4

    Display last 4-digits of number in report

    Try this:

    1. Define a text box in report.
    2. In Control box, enter as per following example (from MS-Access on line help), with the = sign (as =right(MyStr,4))

    Dim AnyString, MyStr
    AnyString = "Hello World" ' Define string.
    MyStr = Right(AnyString, 1) ' Returns "d".
    MyStr = Right(AnyString, 6) ' Returns " World".
    MyStr = Right(AnyString, 20) ' Returns "Hello World".

    I hope this helps. If you search for on-line help, search for the term "functions".

Posting Permissions

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