Solved

Format Percent within a Variable in VBA

Posted on 2014-03-13
2
942 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

930 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now