Solved

Format Percent within a Variable in VBA

Posted on 2014-03-13
2
1,099 Views
Last Modified: 2014-03-13
Need to compare 2 values that are formatted on the query/table as Percent.

However, when I compare the values as variables in vba they revert back to a number.

example:

.33398....  Need to compare as 33.00% and 5.00%
.05

what do I need to do, I tried various formats without success.
format rs.fields(nTierno).value

as
Format(rs.fields(NTierNo).value), Percent, 2 decimal places....
                       If nfld < rs.Fields(nTierNo).Value Then
                            Debug.Print "nTierVal:" & rs.Fields(nTierNo).Value
                           Debug.Print rs.Fields("TotalNetUSExp").Value
                           Debug.Print rs1.Fields(strfld).Value
                           nOvrAmt = 0
                           BkOvrCalc = nOvrAmt
                           GoTo cont:

Open in new window


K
0
Comment
Question by:Karen Schaefer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
GrahamMandeno earned 500 total points
ID: 39927891
Hi Karen

Try:
Format(rs.fields(NTierNo).value, "0.00%")

-- Graham Mandeno [Access MVP 1996-2014]
0
 

Author Closing Comment

by:Karen Schaefer
ID: 39927910
thanks.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question