Let me first explain the application, and state early on that I am an amateur at VBA. I am creating an Access database that will function similar to Computer Aided Dispatch for small police agencies. I have a table called TourT with a PK of ID.
I have a form named CAD_UnitSetup with its record source as the above table, TourT.
I have another form called CAD_CallDispSpl itF with its record source is ActivityT. In the ActivityT table, I have a field named TourID.
There is a subform to the above parent form CAD_CallDispSpl itF named CAD_Log_DispF. The subform's record source is CADLogT. In CADLogT, there is a field called TourID. Through a combo box on the subform CAD_Log_DispF the operator will select the appropriate Unit (TourID) and place that value in the TourID field in the subform's record source table CADLogT.
Also in the CADLogT, there is a number field called ActionID. The Operator will select the appropriate action from a combo box and place that value in the ActionID field. The actions are similar to 1 is for Dispatched as Primary, 2 is Dispatched as Backup, 3 is Arrived, etc.
I created the following Select Case subroutine in the BeforeUpdate event of the subform.
This places the value of 1 or 0 in the UnitAvailable field of the CADLogT. 1 is for Unit is Available, and 2 is Unit Not Available, (I chose to use a number value rather than Yes/No for other reasons).
When the operator selects the appropriate Action on the subform, it places a 1 or 0 in the UnitAvailable field. This simply means that for that particular record, for UnitAvailable is either 1 or 0 based on the selection of the ActionID control. This works fine but it does not achieve my ultimate goal.
My ultimate goal is to have the UnitAvailable field in the first table I described above, (TourT), toggle 1 or 0 to match the 1 or 0 in the latest record in the Log for the related TourID.
Any help would be appreciated, and please remember, I am a beginner to VBA.
Mark
I have a form named CAD_UnitSetup with its record source as the above table, TourT.
I have another form called CAD_CallDispSpl itF with its record source is ActivityT. In the ActivityT table, I have a field named TourID.
There is a subform to the above parent form CAD_CallDispSpl itF named CAD_Log_DispF. The subform's record source is CADLogT. In CADLogT, there is a field called TourID. Through a combo box on the subform CAD_Log_DispF the operator will select the appropriate Unit (TourID) and place that value in the TourID field in the subform's record source table CADLogT.
Also in the CADLogT, there is a number field called ActionID. The Operator will select the appropriate action from a combo box and place that value in the ActionID field. The actions are similar to 1 is for Dispatched as Primary, 2 is Dispatched as Backup, 3 is Arrived, etc.
I created the following Select Case subroutine in the BeforeUpdate event of the subform.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.EmployeeID = DLookup("EmployeeID", "LocalUserT")
If IsNull([EntryDateTime]) Then
[EntryDateTime] = Now()
End If
Select Case ActionID.Value
Case Is = 1: UnitAvailable = 0
Case Is = 2: UnitAvailable = 0
Case Is = 3: UnitAvailable = 0
Case Is = 4: UnitAvailable = 1
Case Is = 6: UnitAvailable = 1
Case Is = 7: UnitAvailable = 1
Case Is = 8: UnitAvailable = 1
Case Is = 10: UnitAvailable = 1
End Select
End Sub
When the operator selects the appropriate Action on the subform, it places a 1 or 0 in the UnitAvailable field. This simply means that for that particular record, for UnitAvailable is either 1 or 0 based on the selection of the ActionID control. This works fine but it does not achieve my ultimate goal.
My ultimate goal is to have the UnitAvailable field in the first table I described above, (TourT), toggle 1 or 0 to match the 1 or 0 in the latest record in the Log for the related TourID.
Any help would be appreciated, and please remember, I am a beginner to VBA.
Mark
Comment