Results 1 to 6 of 6
  1. #1
    JeffChr is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    82

    Custom formatting a calculated text field on a form fails

    I have a form with a select query recordset, which includes a couple calculated fields. The calculations are done in the query. I calculated the fields in VBA and returned a number (long) so I could sort the query on this number. Additionally, I do not want zeros to display in the form, but I cannot get the Format property on the text field correctly set. Any custom format string does not work. If I use one of the pre-defined formats such as "Currency" from the property dialog combo box, it works just fine.



    I have tried various custom format codes, including the "four-state" declaration (+;-;0;Null). But actually any custom format fails. For instance if I put a"#" in the format property it treats the format code literally and displays the pound sign. Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    I am confused. You say the calculation is in the query but then say the calculation is in VBA - the query calls a custom function? If the function returns a long, why would you say this is a text field? Why would you need to apply format in query?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    JeffChr is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    82
    I have this resolved, but thanks for replying. The calcs are "performed" in the query via a function call. I misspoke on the the "text field" and should have said "text box", as in on the form. Which leads to the final question - obviously not applying the format to the query. Sorry for all the confusion. Next time I'll try to be more precise.

    And I have no explanation why it started working. After playing around a bit I put the "#" back into the text BOX format property (without the quotes) and got the results I was looking for. But I don't know why it didn't work many times before that. I changed nothing else.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    What do you mean by 'do not want zeros' - no decimal part? If the value returned by function is truly a number and not a string, set textbox Format to Fixed and DecimalPlaces to 0.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    JeffChr is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    82
    As I mentioned earlier, this issue is resolved. But to address your question, I do not want zeroes to display-just blanks. I accomplished this by formatting the number with just a pound sign in the format property. Thanks for your assistance.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    Thanks for clarifying. Think I understand now. I probably would not have thought of the Format solution. Probably would have used an IIf expression in ControlSource.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Hyperlink Field Custom Formatting?
    By excellenthelp in forum Access
    Replies: 1
    Last Post: 08-12-2014, 02:02 PM
  2. Replies: 1
    Last Post: 03-27-2014, 06:42 AM
  3. Replies: 7
    Last Post: 03-03-2014, 01:36 PM
  4. Calculated Field Formatting
    By RJC in forum Access
    Replies: 8
    Last Post: 08-17-2013, 07:56 AM
  5. Formatting a Calculated Field
    By e_lady333 in forum Queries
    Replies: 0
    Last Post: 03-17-2010, 06:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums