-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm_DeployCreateNewUnitForm.cls
126 lines (122 loc) · 7.55 KB
/
Form_DeployCreateNewUnitForm.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "Form_DeployCreateNewUnitForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Compare Database
Private Sub btnUnitEntryDone_Click()
' Declare variables and assign user entry to variables
Dim strONumbers() As String
Dim strENumbers() As String
Dim strONumberEntry As String
Dim strENumberEntry As String
Dim strCNumberEntry As String
Dim strCrewLeaderEntry As String
' If the form's C Number field or Crew Leader field is empty...
If IsNull(Form_DeployCreateNewUnitForm.CNumber.Value) Or IsNull(Form_DeployCreateNewUnitForm.CrewLeader.Value) Then
msgRequiredMissing = MsgBox("You have not entered either a unit number or crew leader. Keep trying!" & vbCrLf & "(If you are trying to reach the Main Menu, click the Home button.)", vbInformation, "Resource Deployment")
' If the Crew Leader field is incorrect
Else
' Clean up fields and proceed
strCNumberEntry = Right(Trim(Form_DeployCreateNewUnitForm.CNumber.Value), 5)
Form_DeployCreateNewUnitForm.CNumber.Value = "C" + strCNumberEntry
strCrewLeaderEntry = Right(Trim(Form_DeployCreateNewUnitForm.CrewLeader.Value), 5)
Form_DeployCreateNewUnitForm.CrewLeader.Value = "O" + strCrewLeaderEntry
' If the crew leader does not exist in the database...
If Not ResourceExists("O", strCrewLeaderEntry) Then
msgCrewLeaderError = MsgBox("There is a problem with the Crew Leader field. You must enter a valid crew leader.", vbCritical, "Resource Deployment")
' If the crew leader exists in the database...
Else
' If no resources are entered, deploy unit and take no further actions
If IsNull(Form_DeployCreateNewUnitForm.txtONumberEntry.Value) And IsNull(Form_DeployCreateNewUnitForm.txtENumberEntry.Value) Then
' Save user entry for fields that are linked to table
If Me.Dirty Then Me.Dirty = False
Call ResourceCreated("C", strCNumberEntry)
NoResourceMessage = MsgBox("The unit has been deployed. You have assigned no resources to this unit. Resources should be assigned later.", vbInformation, "Resource Deployment")
' If resources are entered, try to mobilize them, then assign them to this unit.
Else
' Save user entry for fields that are linked to table
If Me.Dirty Then Me.Dirty = False
Call ResourceCreated("C", strCNumberEntry)
' If personnel numbers have been entered...
If Form_DeployCreateNewUnitForm.txtONumberEntry.Value <> vbNullString Then
strONumberEntry = Trim(Form_DeployCreateNewUnitForm.txtONumberEntry.Value)
strONumbers = Split(strONumberEntry, vbCrLf)
Call Mobilize(strONumbers)
Call AssignToUnit(strCNumberEntry, strONumbers)
End If
' If equipment numbers have been entered, mobilize and assign those units
If Form_DeployCreateNewUnitForm.txtENumberEntry.Value <> vbNullString Then
strENumberEntry = Trim(Form_DeployCreateNewUnitForm.txtENumberEntry.Value)
strENumbers = Split(strENumberEntry, vbCrLf)
Call Mobilize(, strENumbers)
Call AssignToUnit(strCNumberEntry, , strENumbers)
End If
assignmentConfirmation = MsgBox("The unit has been deployed and the resources have been assigned.", vbInformation, "Resource Deployment")
End If
' Open Main Menu and close This form.
DoCmd.OpenForm "StagingAreaMainMenu"
DoCmd.Close acForm, "DeployCreateNewUnitForm"
End If
End If
End Sub
Private Sub btnUnitEntryAnother_Click()
' Declare variables and assign user entry to variables
Dim strONumbers() As String
Dim strENumbers() As String
Dim strONumberEntry As String
Dim strENumberEntry As String
Dim strCNumberEntry As String
Dim strCrewLeaderEntry As String
' If the form's C Number field or Crew Leader field is empty...
If IsNull(Form_DeployCreateNewUnitForm.CNumber.Value) Or IsNull(Form_DeployCreateNewUnitForm.CrewLeader.Value) Then
msgRequiredMissing = MsgBox("You have not entered either a unit number or crew leader. Keep trying!" & vbCrLf & "(If you are trying to reach the Main Menu, click the Home button.)", vbInformation, "Resource Deployment")
' If the Crew Leader field is incorrect
Else
' Clean up fields and proceed
strCNumberEntry = Right(Trim(Form_DeployCreateNewUnitForm.CNumber.Value), 5)
Form_DeployCreateNewUnitForm.CNumber.Value = "C" + strCNumberEntry
strCrewLeaderEntry = Right(Trim(Form_DeployCreateNewUnitForm.CrewLeader.Value), 5)
Form_DeployCreateNewUnitForm.CrewLeader.Value = "O" + strCrewLeaderEntry
' If the crew leader does not exist in the database...
If Not ResourceExists("O", strCrewLeaderEntry) Then
msgCrewLeaderError = MsgBox("There is a problem with the Crew Leader field. You must enter a valid crew leader.", vbCritical, "Resource Deployment")
' If the crew leader exists in the database...
Else
' If no resources are entered, deploy unit and take no further actions
If IsNull(Form_DeployCreateNewUnitForm.txtONumberEntry.Value) And IsNull(Form_DeployCreateNewUnitForm.txtENumberEntry.Value) Then
' Save user entry for fields that are linked to table
If Me.Dirty Then Me.Dirty = False
Call ResourceCreated("C", strCNumberEntry)
NoResourceMessage = MsgBox("The unit has been deployed. You have assigned no resources to this unit. Resources should be assigned later.", vbInformation, "Resource Deployment")
' If resources are entered, try to mobilize them, then assign them to this unit.
Else
' Save user entry for fields that are linked to table
If Me.Dirty Then Me.Dirty = False
Call ResourceCreated("C", strCNumberEntry)
' If personnel numbers have been entered...
If Form_DeployCreateNewUnitForm.txtONumberEntry.Value <> vbNullString Then
strONumberEntry = Trim(Form_DeployCreateNewUnitForm.txtONumberEntry.Value)
strONumbers = Split(strONumberEntry, vbCrLf)
Call Mobilize(strONumbers)
Call AssignToUnit(strCNumberEntry, strONumbers)
End If
' If equipment numbers have been entered, mobilize and assign those units
If Form_DeployCreateNewUnitForm.txtENumberEntry.Value <> vbNullString Then
strENumberEntry = Trim(Form_DeployCreateNewUnitForm.txtENumberEntry.Value)
strENumbers = Split(strENumberEntry, vbCrLf)
Call Mobilize(, strENumbers)
Call AssignToUnit(strCNumberEntry, , strENumbers)
End If
assignmentConfirmation = MsgBox("The unit has been deployed and the resources have been assigned.", vbInformation, "Resource Deployment")
End If
' Close and reopen the form
DoCmd.Close acForm, "DeployCreateNewUnitForm"
DoCmd.OpenForm "DeployCreateNewUnitForm"
End If
End If
End Sub