oxicottin
Learning by pecking away....
- Local time
- Today, 06:27
- Joined
- Jun 26, 2007
- Messages
- 851
Hello, what am I doing incorrect? The example below needs to to this, If its a new record and its your first selection in cboProduct then run the test function.
Next lines are if there already is a selection and your changing it then give a message box to ask a question and yes do this else do that and call test either or to disable or enable controls based on your selection. What is happening is it works (as in enable/disable controls) on a new record and only on the first time something is selected in the combo box there after it does nothing.
Code:
If IsNull(Me.cboProductID) Then
Call test
End If
Exit Sub
Next lines are if there already is a selection and your changing it then give a message box to ask a question and yes do this else do that and call test either or to disable or enable controls based on your selection. What is happening is it works (as in enable/disable controls) on a new record and only on the first time something is selected in the combo box there after it does nothing.
Code:
Private Sub cboProductID_AfterUpdate()
'--------------------------------------------------------------------------------------------------
' Clear controls if product is changed and requery length to get new sizes
'--------------------------------------------------------------------------------------------------
If IsNull(Me.cboProductID) Then
Call test
End If
Exit Sub
If Not IsNull(Me.cboProductID) Then
If MsgBox("Do you want to clear all data for this row?", vbYesNo + vbQuestion) = vbYes Then
Me.txtSLegCS = Null
Me.txtSLegNCS = Null
Me.txtBeadCS = Null
Me.txtBeadNCS = Null
Me.txtPLegCS = Null
Me.txtPLegNCS = Null
Me.txtGapHigh = Null
Me.txtGapLow = Null
Me.txtAngle = Null
Me.cboProductLength.SetFocus ' Sets focus to Length combo box
Me.txtProductLength = Null ' Clears Text Box Product Length
Me.cboProductLength.Requery ' Requerys Product length to get new size
Call test
Else
'Only clear product and length
Me.cboProductLength.SetFocus ' Sets focus to Length combo box
Me.txtProductLength = Null ' Clears Text Box Product Length
Me.cboProductLength.Requery ' Requerys Product length to get new size
Call test
End If
End If
End Sub
Private Function test()
With Forms!frm_ShiftDay!frm_ShiftMachinesRanSubform.Form!frm_MachineOutputSubForm.Form
Select Case !cboProductID
Case 21, 10
Me.txtBeadCS.Enabled = False
Me.txtBeadNCS.Enabled = False
Me.txtAngle.Enabled = False
Me.txtAngle = Null
Me.txtBeadCS = Null
Me.txtBeadNCS = Null
Me.txtGapHigh.Enabled = True
Me.txtGapLow.Enabled = True
Case Else
Me.txtBeadCS.Enabled = True
Me.txtBeadNCS.Enabled = True
Me.txtAngle.Enabled = True
Me.txtGapHigh.Enabled = False
Me.txtGapLow.Enabled = False
Me.txtGapHigh = Null
Me.txtGapLow = Null
End Select
End With
End Function