percentage in combo box format

Posted on 2013-09-26
Medium Priority
Last Modified: 2013-09-26
Dear experts -
I have a combo box with these columns:
column 0: [decimal number between 0 and 1]
column 1: textual representation of same: 0%, 20%, 60%, 100% [just a few specified values]
column 2: description text (explaining how this value is used, e.g., 'a complete certainty').

Column 0 is the bound column.

So far, so good.

Now, I have another control on the form that has other default decimal values (e.g., .5 or .8); if the user selected a value in THIS combo box, I want to give the user the option to make THIS the selection in the previously mentioned combo box.

I have been attempting this with the code below. HOWEVER, the other columns are absent and the combo box is showing blank. How do I deal with this - i.e., if user wishes to use the new value, how do I populate the combo box properly?



If Nz(Me.cboProbability, 0) = 0 Then
    Me.cboProbability = Val(Me.cboStatus_ID.Column(2))
ElseIf Me.cboProbability <> Val(Me.cboStatus_ID.Column(2)) Then
    If MsgBox("The default probability for this stage is " & Val(Me.cboStatus_ID.Column(2)) * 100 & "%. Would you like to use the default value?", vbYesNo) = vbYes Then
        Me.cboProbability = Val(Me.cboStatus_ID.Column(2))
    End If
End If
Question by:terpsichore
  • 3
LVL 74

Accepted Solution

Jeffrey Coachman earned 2000 total points
ID: 39525697
Just leave all the values as raw decimal
.01, .02, .03, ...etc
You can then just format the individual controls by setting the "Format" property to: "Percent"
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39525718
Oh, I misunderstood your question.

1. It looks like your Column Indexes are off.
If you have two columns in your combobox, .column(0) is the first,  and .column(1) is the second (these are zero based values).

So give that a try...

Also, not sure why you need the Val() function there...?

Author Closing Comment

ID: 39525774
this was the simple answer; i had a second column displaying the percentage, which was superfluous and conflicting when i was adding the value from the other table (since the displayed column didn't exist. Thanks!
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39525791
Yes, I was not "exactly" sure of your question...
So I threw out both of those suggestions...

Glad I could help...

...And just to be clear, ...a combobox will display the value as text, but you can still reference the column and get the correct "numeric" value, without the Val() function...



Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I have had my own IT business for a very long time. I started mostly with hardware and after about a year started to notice a common theme. I had shelves with software boxes -- Peachtree, Quicken, Sage, Ouickbooks -- and yet most of my clients were…
A quick solution showing how to control and open a POS Cash Register Drawer using VBA with MS Access.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…

586 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