PDA

View Full Version : Solved: Easy format Question



tccmdr
06-18-2007, 12:19 AM
One to really test the Brains Trust:giggle

How can I ensure that my combobox returns it's value in a "0%" format:banghead:

xld
06-18-2007, 12:20 AM
Uo load it such



Combobox1.AddItem Format(value,"0%")

tccmdr
06-18-2007, 12:28 AM
Ahhhh......Mr.X


T1.AddItem Format(Value, "0%")

Runtime Error 70:

Permission Denied:doh:

unmarkedhelicopter
06-18-2007, 01:03 AM
Where is the code located ?
You generally need a better address.
e.g. if the code is in the form then :- "Me.T1.AddItem Format(Value, "0%")"
I assume T1 is your combobox (strange naming convention !)
I assume "Value" is your variable ? (What is it declared as ? and what is it's value at the time of execution ?)

xld
06-18-2007, 02:03 AM
Ahhhh......Mr.X


T1.AddItem Format(Value, "0%")
Runtime Error 70:

Permission Denied:doh: Value was just used to show you where to post your value. I had no idea whether it was a variable, a range or what. You need to plugin the real value.

tccmdr
06-18-2007, 04:05 AM
Mr.X.....had to move to another PC :motz2:

My workbook contains an 'Audit' userform to review a supplier's compliance on a number of items.

T1 through 9 refers to 9 separate comboboxes. Each share the same property rowsource - "Score". "Score" is a defined range of percentages from 0%, incrementing by 10%, to 100%. Selecting a percentage sets the compliance tolerence level required for a particular item.

My problem, however, is when the value is selected, it's decimal format is shown. I want to see the percentage format:whistle:

xld
06-18-2007, 04:33 AM
Don't use RowSources, it binds the combobox and I think that is a bad idea, load it with eth data as I showed.

tccmdr
06-18-2007, 02:20 PM
OK Mr.X, I did as you suggested:whip

As each combobox will be using the same scoring items, is there a way I can set up the "AddItem" list so I can attach it to all the comboboxes.

That way I don't have to recreate the list for every combobox: pray2:

xld
06-18-2007, 02:25 PM
Something like this



LoadCombo Me.ComboBox1
LoadCombo Me.ComboBox2
'etc


Private Sub LoadCombo(ByRef cb AsMSForms.CombBox)

With cb

.Additem Format(value1,"0%")
.Additem Format(value2,"0%")
.Additem Format(value3,"0%")
'etc
End With
End Sub


with real values of course

tccmdr
06-18-2007, 03:02 PM
Mr.X

I'm still getting errors....:banghead:


Private Sub UserForm_Activate()
LoadCombo Me.To1
LoadCombo Me.To2
LoadCombo Me.To3
LoadCombo Me.To4
LoadCombo Me.To5
LoadCombo Me.To6
LoadCombo Me.To7
LoadCombo Me.To8
LoadCombo Me.To9
End Sub
Private Sub LoadCombo(ByRef cb As MSForms.CombBox)

With cb

.AddItem Format(0, "0%")
.AddItem Format(0.1, "0%")
.AddItem Format(0.2, "0%")
.AddItem Format(0.3, "0%")
.AddItem Format(0.4, "0%")
.AddItem Format(0.5, "0%")
.AddItem Format(0.6, "0%")
.AddItem Format(0.7, "0%")
.AddItem Format(0.8, "0%")
.AddItem Format(0.9, "0%")
.AddItem Format(1, "0%")

End With
End Sub

xld
06-18-2007, 03:10 PM
I missed a letter



Option Explicit

Private Sub cmdOK_Click()
Me.Hide
End Sub

Private Sub cmdQuit_Click()
Me.Hide
End Sub

Private Sub UserForm_Activate()
LoadCombo Me.To1
LoadCombo Me.To2
LoadCombo Me.To3
LoadCombo Me.To4
LoadCombo Me.To5
LoadCombo Me.To6
LoadCombo Me.To7
LoadCombo Me.To8
LoadCombo Me.To9
End Sub
Private Sub LoadCombo(ByRef cb As MSForms.ComboBox)

With cb

.AddItem Format(0, "0%")
.AddItem Format(0.1, "0%")
.AddItem Format(0.2, "0%")
.AddItem Format(0.3, "0%")
.AddItem Format(0.4, "0%")
.AddItem Format(0.5, "0%")
.AddItem Format(0.6, "0%")
.AddItem Format(0.7, "0%")
.AddItem Format(0.8, "0%")
.AddItem Format(0.9, "0%")
.AddItem Format(1, "0%")

End With
End Sub

tccmdr
06-18-2007, 04:19 PM
Mr.X

I must be going blind:bug:

Which letter did you miss:think:

tccmdr
06-18-2007, 04:37 PM
Mr.X.........'o' Found it:whistle:



Thanks again for your help
:friends:

mdmackillop
06-19-2007, 09:28 AM
Easy format Question
:rotflmao: