Text Box Conditional

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dev1
    New Member
    • Feb 2008
    • 38

    #1

    Text Box Conditional

    All -

    I have one box tha is a drop down with numeric values. I have a second textbox that has a percentage value. I'm trying to set a condition based on the first dropdown box that when the value changes, the second textbox will be updated with the appropriate value.

    Dropdown - Textbox 'Class'
    Values 0,1,2,3,4,5,6

    Textbox 'Likeihood of sale'
    Values 100,90,33,20,5, 0,0


    So when a user changes the dropdown value to say 4 then the percentage textbox value will be changed to 5%

    Here is my sample code:If Me.Class = "0" Then
    Me.Likelihood_o f_Sale = "100"
    End If

    ElseIf Me.Class = "1" Then
    Me.Likelihood_o f_Sale = "90"
    ElseIf Me.Class = "2" Then
    Me.Likelihood_o f_Sale = 33
    ElseIf Me.Class = "3" Then
    Me.Likelihood_o f_Sale = 20
    ElseIf Me.Class = "4" Then
    Me.Likelihood_o f_Sale = 0.05
    ElseIf Me.Class = "5" Then
    Me.Likelihood_o f_Sale = 0
    ElseIf Me.Class = "6" Then
    Me.Likelihood_o f_Sale = 0



    Thanks for any help on this

    -Dev1
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by Dev1
    All -

    I have one box tha is a drop down with numeric values. I have a second textbox that has a percentage value. I'm trying to set a condition based on the first dropdown box that when the value changes, the second textbox will be updated with the appropriate value.

    Dropdown - Textbox 'Class'
    Values 0,1,2,3,4,5,6

    Textbox 'Likeihood of sale'
    Values 100,90,33,20,5, 0,0

    So when a user changes the dropdown value to say 4 then the percentage textbox value will be changed to 5%

    Here is my sample code:If Me.Class = "0" Then
    Me.Likelihood_o f_Sale = "100"
    End If

    ElseIf Me.Class = "1" Then
    Me.Likelihood_o f_Sale = "90"
    ElseIf Me.Class = "2" Then
    Me.Likelihood_o f_Sale = 33
    ElseIf Me.Class = "3" Then
    Me.Likelihood_o f_Sale = 20
    ElseIf Me.Class = "4" Then
    Me.Likelihood_o f_Sale = 0.05
    ElseIf Me.Class = "5" Then
    Me.Likelihood_o f_Sale = 0
    ElseIf Me.Class = "6" Then
    Me.Likelihood_o f_Sale = 0



    Thanks for any help on this

    -Dev1
    Assuming your Combo Box name is cboNumericValue s, then place the following code in the AfterUpdate() Event of this Combo Box, namely:
    [CODE=vb]
    Private Sub cboNumericValue s_AfterUpdate()
    Select Case Me![cboNumericValue s]
    Case 0
    Me![Likelihood_of_S ale] = 100
    Case 1
    Me![Likelihood_of_S ale] = 90
    Case 2
    Me![Likelihood_of_S ale] = 33
    Case 3
    Me![Likelihood_of_S ale] = 20
    Case 4
    Me![Likelihood_of_S ale] = 0.05
    Case 5, 6
    Me![Likelihood_of_S ale] = 0
    Case Else
    Me![Likelihood_of_S ale] = Null
    End Select
    End Sub[/CODE]

    Comment

    Working...