Solved

Format Percent within a Variable in VBA

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

758 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

18 Experts available now in Live!

Get 1:1 Help Now