Convert Data Types via Combobox

  • Thread starter Thread starter yiotaa
  • Start date Start date
Y

yiotaa

I have I combo box and i want to convert the data type of anohter field every
based on the that combo box.
The combo box has two values "%" and "Num", if i choose "%" then the field i
want to accepted percentages value else if i choose "Num" i want it to
accepted general number, integer.
Please help me!!
 
In the combo box After Update event (SomeField is the field in which Percent
or Number is stored), and txtOtherField is the text box bound to the number
field:

If Me.SomeField = "Percent" Then
Me.txtOtherField.Format = "Percent"
Else
Me.txtOtherField.Format = 0
End If

You will need similar code in the form's Current event.

This will render 100 as 10000%. To have 100 formatted as 100% I think you
will need to do something such as place the value into an unbound text box
via code that divides by 100 first. Why would the user select percentage at
some times and integer at others for the same field? What is the real-world
situation behind what you are trying to do?
 
Back
Top