Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2004
    Posts
    46

    Unanswered: Formatting a number in a report

    ="Our reference: DCX" & [case_number] & " Transaction" & Format(Now()," yyyy mmm dd hh:nn")

    The above results in the following appearing on the Report:

    Our reference: DCX 1 Transa..... etc.

    The number after DCX is supposed to come out as 0001.

    How do I change the code to format it as such.

  2. #2
    Join Date
    Mar 2004
    Posts
    118
    format([number], 0000)

  3. #3
    Join Date
    Dec 2004
    Posts
    46
    It doesnt seem to work:

    ="Our reference: DCX" & Format([case_number],0) & " Exclusion" & Format(Now()," yyyy mmm dd hh:nn")

    It changes the 0000 into a 0

    -----DCX" & Format([case_number],0) -----

    Any suggestions. I'm I putting it in the right context?

  4. #4
    Join Date
    Mar 2004
    Posts
    118
    If the number is stored as text this should not be a problem.

    If the number is stored as a number there are 2 things:

    1. Format the textbox you are outputting it to by setting the "format" control to 0000 (or however many digits you want).

    2. change it to a string in code:

    Code:
    dim n as string
    
    n = format([case_number], "0000")
    
    me.yourtextbox = "Our reference: DCX" & n & " Exclusion" & Format(Now()," yyyy mmm dd hh:nn")
    I think the format function converts the data to a string for display purpouses... But dont quote me on that .

  5. #5
    Join Date
    Sep 2004
    Location
    Charlotte, NC
    Posts
    164
    davindersangha,

    The part of your expression that says Format([case_number],0) needs to be Format([case_number],"0000") . Don't forget the quotation marks around the zeroes.

    TD

Posting Permissions

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