Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008
    Location
    Leyland in NW England, UK
    Posts
    19

    Question Unanswered: Inserting Colon into Number Field

    Hiya,
    One of fields displaying in my report is StartTime. It's set up as a number field so when displays am getting "1601" or "800".

    What code do I need to use in order to get a colon in middle of number e.g. "16:01" or "8:00"

  2. #2
    Join Date
    May 2003
    Location
    UK
    Posts
    233
    Should this not be a date/time field? If set the field to show only the mm:ss

  3. #3
    Join Date
    Oct 2007
    Posts
    10
    You can either click on properties of the field and modify the "Display String" attribute...

    .. this has an automatic variable "CurrentFieldValue". You could use CStr(CurrentFieldValue) and parse out substrings and concatenate them with a colon..

    ..but, this is what i do for SSNs which get returned as "123456789":

    1) The CStr() function lets you specifiy a masking pattern and where to insert "thousands seperators" .. which, are usually commas... when changing a number to a string

    2) The CStr() function also lets you specify a *different* "thousands seperator" at your own intervals.

    3) For example, to change "123456789" to "123-45-6789" you would put the following code in the "Display String" attribute of your numeric field

    CStr(ToNumber(CurrentFieldValue),"###,##,####",0,"-")

    4) So, for your code.. you would probably modify it like this:

    CStr(ToNumber(CurrentFieldValue),"##,##",0,":")

    5) I think you can also specify a decimal seperator so if your numbers where 16.01 , you could change the decimal to a colon. Hit F1 and lookup the options for CStr()

    ......

    ...or... you could create a function that does this same thing, but instead of CurrentFieldValue, you would use the name of the field, and then you would have to insert the function into your report and take out the old field. I like "Display String" because it keeps the same field and just changes what gets displayed.

  4. #4
    Join Date
    Jun 2008
    Location
    Leyland in NW England, UK
    Posts
    19
    Thanks Devbloch - was very helpful

Posting Permissions

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