Form Code
Option Compare Database
Private Sub cboStation_AfterUpdate()
Me.cboStaff = Null
Me.cboStaff.Enabled = True
Me.cboStaff.Requery
Me.cboStaff.SetFocus
End Sub
Public Sub cboStaff_AfterUpdate()
Me.sbfNew_PPE.Enabled = True
Me.sbfNew_PPE.Form.txtChipNumber.Enabled = True
Me.sbfNew_PPE.SetFocus
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.cboStation.SetFocus
Me.cboStaff.Enabled = False
Me.sbfNew_PPE.Enabled = False
End Sub
Private Sub cmbAddRecord_Click()
On Error GoTo Err_cmbAddRecord_Click
Err_cmbAddRecord_Click:
If IsNull(cboStation) Then
MsgBox ("You have to enter data first!")
Me.cboStation.SetFocus
Cancel = True
ElseIf IsNull(cboStaff) Then
MsgBox ("You have to enter data first!")
Me.cboStaff.SetFocus
Cancel = True
Else
DoCmd.RunCommand acCmdSaveRecord
Me.cboStaff = Null
Me.cboStaff.SetFocus
Me!sbfNew_PPE.Form!cboGarmentType.Enabled = False
Me!sbfNew_PPE.Form!cboSize.Enabled = False
Me!sbfNew_PPE.Form!cboFitting.Enabled = False
Me.sbfNew_PPE.Enabled = False
End If
Exit_cmbAddRecord_Click:
Exit Sub
Err_cmbAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmbAddRecord_Click
End Sub
Private Sub cmbClose_Click()
Me.Undo
DoCmd.Close acForm, "frmAdd_New_PPE"
End Sub
Public Sub cmdExitAndSave_Click()
On Error GoTo Err_cmdExitAndSave_Click
Err_cmbAddRecord_Click:
If IsNull(cboStation) Then
MsgBox ("You have to enter data first!")
Me.cboStation.SetFocus
Cancel = True
ElseIf IsNull(cboStaff) Then
MsgBox ("You have to enter data first!")
Me.cboStaff.SetFocus
Cancel = True
Else
DoCmd.GoToRecord , , acNewRec
DoCmd.Close acForm, "frmAdd_New_PPE"
End If
Exit_cmdExitAndSave_Click:
Exit Sub
Err_cmdExitAndSave_Click:
MsgBox Err.Description
Resume Exit_cmdExitAndSave_Click
End Sub