PrettyMess
Board Regular
- Joined
- Feb 10, 2015
- Messages
- 66
I'm hoping someone may be able to help with this I have managed to get the basic's but I'm a bit stuck with the next stage.
Currently I have been able to grey out the required fields when the various options are selected from my combo box "Type" I have also been able to get the code to check my fields to make sure that something is entered into the non greying out fields.
However the part I am stuck on is that when my 'Type' drop down is selected I need to make the non greyed out boxes compulsory.
The user must select one of the 4 options in the 'type' box (so i need to make sure they have selected one or they get prompted to pick one) then if the user selects the option for voice in the type field all boxes become white and I need the user to fill them all in (with no gaps) so I want to make sure it all gets filled in or else they get prompted too go back and fill in. where as if the user selects Alarm they don't need to complete any of the information on the right hand side so it gets greyed out and they are able to proceed onto the next record
Currently I have been able to grey out the required fields when the various options are selected from my combo box "Type" I have also been able to get the code to check my fields to make sure that something is entered into the non greying out fields.
However the part I am stuck on is that when my 'Type' drop down is selected I need to make the non greyed out boxes compulsory.
The user must select one of the 4 options in the 'type' box (so i need to make sure they have selected one or they get prompted to pick one) then if the user selects the option for voice in the type field all boxes become white and I need the user to fill them all in (with no gaps) so I want to make sure it all gets filled in or else they get prompted too go back and fill in. where as if the user selects Alarm they don't need to complete any of the information on the right hand side so it gets greyed out and they are able to proceed onto the next record
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(TypeList.Value) Then
MsgBox "You Must Enter a Type"
Cancel = True
TypeList.SetFocus
Exit Sub
End If
If Me.DDI.Enabled = True Then
If Me.txtFldA.Text = "" Then
If IsNull(DDI.Value) Then
MsgBox "You Must Enter a Number in DDI"
Cancel = True
DDI.SetFocus
Exit Sub
End If
If IsNull(Extn.Value) Then
MsgBox "You Must Enter a Number in Extn"
Cancel = True
Extn.SetFocus
Exit Sub
End If
If IsNull(Location.Value) Then
MsgBox "You Must Enter a Location"
Cancel = True
Location.SetFocus
Exit Sub
End If
If IsNull(Analogue.Value) Then
MsgBox "You Must Make a selection Analogue/Cisco"
Cancel = True
Analogue.SetFocus
Exit Sub
End If
If IsNull(StaffNumber.Value) Then
MsgBox "You Must Include a staff number"
Cancel = True
StaffNumber.SetFocus
Exit Sub
End If
If IsNull(Firstname.Value) Then
MsgBox "You Must Include a Firstname"
Cancel = True
Firstname.SetFocus
Exit Sub
End If
If IsNull(Surname.Value) Then
MsgBox "You Must Include a Surname"
Cancel = True
Surname.SetFocus
Exit Sub
End If
If IsNull(UserCode.Value) Then
MsgBox "You Must Include a Username"
Cancel = True
UserCode.SetFocus
Exit Sub
End If
If IsNull(DeptCode.Value) Then
MsgBox "You Must Include a Department"
Cancel = True
DeptCode.SetFocus
Exit Sub
End If
Select Case Me.TypeList.Value
Case Is = "Voice"
Me.StaffNumber.Enabled = True
Me.Firstname.Enabled = True
Me.Surname.Enabled = True
Me.UserCode.Enabled = True
Me.DeptCode.Enabled = True
Me.FaxLine.Enabled = False
Case Is = "Fax"
Me.StaffNumber.Enabled = False
Me.Firstname.Enabled = False
Me.Surname.Enabled = False
Me.UserCode.Enabled = False
Me.DeptCode.Enabled = False
Me.FaxLine.Enabled = True
Case Is = "Alarm"
Me.StaffNumber.Enabled = False
Me.Firstname.Enabled = False
Me.Surname.Enabled = False
Me.UserCode.Enabled = False
Me.DeptCode.Enabled = False
Me.FaxLine.Enabled = False
Case Is = "Lift"
Me.StaffNumber.Enabled = False
Me.Firstname.Enabled = False
Me.Surname.Enabled = False
Me.UserCode.Enabled = False
Me.DeptCode.Enabled = False
Me.FaxLine.Enabled = False
Case Is = "Hunt Group"
Me.StaffNumber.Enabled = False
Me.Firstname.Enabled = False
Me.Surname.Enabled = False
Me.UserCode.Enabled = False
Me.DeptCode.Enabled = False
Me.FaxLine.Enabled = False
End Select
End Sub
Private Sub TypeList_AfterUpdate()
Select Case Me.TypeList.Value
Case Is = "Voice"
Me.StaffNumber.Enabled = True
Me.Firstname.Enabled = True
Me.Surname.Enabled = True
Me.UserCode.Enabled = True
Me.DeptCode.Enabled = True
Me.FaxLine.Enabled = False
Case Is = "Fax"
Me.StaffNumber.Enabled = False
Me.Firstname.Enabled = False
Me.Surname.Enabled = False
Me.UserCode.Enabled = False
Me.DeptCode.Enabled = False
Me.FaxLine.Enabled = True
Case Is = "Alarm"
Me.StaffNumber.Enabled = False
Me.Firstname.Enabled = False
Me.Surname.Enabled = False
Me.UserCode.Enabled = False
Me.DeptCode.Enabled = False
Me.FaxLine.Enabled = False
Case Is = "Lift"
Me.StaffNumber.Enabled = False
Me.Firstname.Enabled = False
Me.Surname.Enabled = False
Me.UserCode.Enabled = False
Me.DeptCode.Enabled = False
Me.FaxLine.Enabled = False
Case Is = "Hunt Group"
Me.StaffNumber.Enabled = False
Me.Firstname.Enabled = False
Me.Surname.Enabled = False
Me.UserCode.Enabled = False
Me.DeptCode.Enabled = False
Me.FaxLine.Enabled = False
End Select
End Sub