Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Format Percent within a Variable in VBA

Posted on 2014-03-13
2
Medium Priority
?
1,177 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 2000 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

722 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