Hi Guys
hope you all had a great christmas and a happy nerw year
i have a problem with some code that works out the speed of a machine
Private Sub SOIMachineConditiontxtbox_AfterUpdate()
'This will Work Out the Chartered Speed For A machine
Dim Speed As String
Speed = 61 / Me.ACTUALLAYLENGHTTXTBOX * 1000
MsgBox Me.SOIMachineConditiontxtbox
If Me.SOIMachineConditiontxtbox = 3 And Speed < 6000 Then
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = Speed
Else
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = 6000
End If
end sub
MsgBox Me.SOIMachineConditiontxtbox i show the id of the machine when the afterupdate event fires
Me.ACTUALLAYLENGHTTXTBOX is a feild on a form that a user fills in "This is a number feild"
Me.SOIMachineConditiontxtbox is a drop down list containing machine names, 3 in the above code is it's id number
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX is a feild on the form that will record the the sum
the code above works when selecting the machine with the ID of 3 and the correct value is placed into the me.CHARTEREDSPEEDTWISTPERMETERTXTBOX on the form
The problem is that i have 6 machines in total, if i replace the above code with the code below, no matter what i do the variable "Speed" always shows 5000?
Private Sub SOIMachineConditiontxtbox_AfterUpdate()
'This will Work Out the Chartered Speed For A machine
Dim Speed As String
Speed = 61 / Me.ACTUALLAYLENGHTTXTBOX * 1000
MsgBox Me.SOIMachineConditiontxtbox
If Me.SOIMachineConditiontxtbox = 1 And Speed < 4500 Then
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = Speed
Else
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = 4500
End If
If Me.SOIMachineConditiontxtbox = 2 And Speed < 4500 Then
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = Speed
Else
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = 4500
End If
If Me.SOIMachineConditiontxtbox = 3 And Speed < "6000" Then
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = Speed
Else
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = 6000
End If
If Me.SOIMachineConditiontxtbox = 4 And Speed < 5000 Then
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = Speed
Else
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = 5000
End If
If Me.SOIMachineConditiontxtbox = 5 And Speed < 5000 Then
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = Speed
Else
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = 5000
End If
If Me.SOIMachineConditiontxtbox = 6 And Speed < 5000 Then
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = Speed
Else
Me.CHARTEREDSPEEDTWISTPERMETERTXTBOX = 5000
End If
end sub
i can't get my head around how to do this, im sure i am doing something silly but for the life of me i can't seem to work it out.
any help would be fantastic
Kind regards
Steve