Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Are you using dlookup to get your value? If so that returns a variant which may be the issue so suggest surrounding it with cdbl

  2. #17
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by Blings View Post
    The box in orange is formatted as Percent, however, the value is 0.025 when it should be 2.5%.
    As already mentioned, if it was formatted as Percent, the percentage sign would be showing?

    That should give you a clue as to what is wrong?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #18
    Blings's Avatar
    Blings is offline Competent Performer
    Windows 10 Office 365
    Join Date
    May 2020
    Location
    London, UK
    Posts
    125
    Quote Originally Posted by Welshgasman View Post
    As already mentioned, if it was formatted as Percent, the percentage sign would be showing?

    That should give you a clue as to what is wrong?
    Can you not see in my first post that it is formatted as "Percent"? Hence my question... as it's not showing as a Percentage when it is formatted as a Percent.

  4. #19
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Ajax and I both suggested running the text box control source through the CDbl function. Have you given that a shot?

  5. #20
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    have you looked at post #16?

    this comment

    After testing that access throws the code out like this ""=For"m"at(["d\isc"ou"n"t],Percent)"
    implies you copied this to the format property, not the controlsource property


    And I don't understand your control source - if discount is on your form, you don't need forms!longformname.form and if it is on a subform you would have longformname.form.discount. And anyway, forms!longformname.form.discount is not a valid path. The only other option is it would be on a completely separate form would appear to not be open anyway and would be forms!longformname.discount. So how are you getting it to work?

  6. #21
    Blings's Avatar
    Blings is offline Competent Performer
    Windows 10 Office 365
    Join Date
    May 2020
    Location
    London, UK
    Posts
    125
    Hello Ajax & kd2017, yes, the Suppliers table has a field of DiscountPercentageID which looks up to the SuppliersDiscount table which has two fields 1) DiscountPercentageID and 2) Percent. The data in Percent is formatted as Percent.

    I need to research what the CDbl function is.

    The query returns the percent, however, when I fetch the value it doesn't display as the percent it should.

    Click image for larger version. 

Name:	SupplierDiscountPercentageForm.PNG 
Views:	10 
Size:	98.2 KB 
ID:	45922
    Not sure what I am doing wrong.
    Attached Thumbnails Attached Thumbnails SupplierDiscountPercentageQuery.PNG  

  7. #22
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    In your discount % text box control soure where it says =[Forms]![blah blah blah] send all that through the CDbl function so it looks like =CDbl([Forms]![blah blah blah])

    CDbl is short for convert double. I see now that your source is a column from a combo, that column is a string I'm guessing. CDbl should convert it back to a decimal number that access understands how to display as a percentage.

  8. #23
    Blings's Avatar
    Blings is offline Competent Performer
    Windows 10 Office 365
    Join Date
    May 2020
    Location
    London, UK
    Posts
    125
    This worked! =Format([Discount],"Percent") as the control source, thanks Minty. Sorry for all the questions and back and forth on this one! All, thanks for helping.

    See it in action!
    Attached Thumbnails Attached Thumbnails SupplierCreditorRecon.PNG  

  9. #24
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    and the reason it is being treated as text is that you are getting it via a combo - the data presented in a combo or listbox is treated as text

  10. #25
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    and by the way, now you have used the format function rather than the property, the value is definitely text - so you cannot use it in any calculations

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 11-07-2017, 06:07 PM
  2. Replies: 1
    Last Post: 07-19-2014, 01:04 PM
  3. Replies: 2
    Last Post: 08-02-2013, 01:38 AM
  4. Replies: 2
    Last Post: 06-28-2013, 11:15 PM
  5. Replies: 2
    Last Post: 05-13-2011, 02:34 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