L
lcox400w
I have a subform where users will enter information on people. First a user
will enter information about an event on the main tab. Then the user selects
the person tab where the person sub-form is located. To ensure data is
entered properly, I need to ensure that certain types of people are entered
based on the incident (case type).
I have written the below code, but its not working correctly. I think I am
close, but could use a little help. Here is how the code should work.
If the casetype (main form) = Murder, then ONE of the person records MUST
have a "Victim". You can have multiple person records for an incident. If
the entire event is a new record, then generally the first record would be
new and the person type would be "victim". But my code changes each person
to "victim" if I try and enter more than 1 person record. also if its an old
record, i'm afraid it will erase the current person type.
In addition, there are some instances where a casetype will require 2
mandatory person types as shown below. I cant figure out how to get the code
to fill in both of those types. I think I may be approaching it wrong, in
that maybe I need to complete 1 person record, before the code goes onto
making a second record, but I cant figure out how to identify when the code
has completed 1 record and ready to start a new record so I can force the
mandatory person type in the second "new" record.
Private Sub PersonType_BeforeUpdate(Cancel As Integer)
If NewRecord = True Then
If Forms!frmmainentry.CaseType = "Murder" Then Me.PersonType.Value =
"Victim"
Me.HomicideNO.SetFocus
Me.PersonType.Enabled = False
ElseIf Forms!frmmainentry.CaseType = "OIS - Fatal" Then
Me.PersonType.Value = "OIS Decedent"
NewRecord.Me.PersonType.Value = "Officer"
ElseIf Forms!frmmainentry.CaseType = "ICD" Then Me.PersonType.Value =
"ICD Decedent"
End If
Else
End If
End Sub
will enter information about an event on the main tab. Then the user selects
the person tab where the person sub-form is located. To ensure data is
entered properly, I need to ensure that certain types of people are entered
based on the incident (case type).
I have written the below code, but its not working correctly. I think I am
close, but could use a little help. Here is how the code should work.
If the casetype (main form) = Murder, then ONE of the person records MUST
have a "Victim". You can have multiple person records for an incident. If
the entire event is a new record, then generally the first record would be
new and the person type would be "victim". But my code changes each person
to "victim" if I try and enter more than 1 person record. also if its an old
record, i'm afraid it will erase the current person type.
In addition, there are some instances where a casetype will require 2
mandatory person types as shown below. I cant figure out how to get the code
to fill in both of those types. I think I may be approaching it wrong, in
that maybe I need to complete 1 person record, before the code goes onto
making a second record, but I cant figure out how to identify when the code
has completed 1 record and ready to start a new record so I can force the
mandatory person type in the second "new" record.
Private Sub PersonType_BeforeUpdate(Cancel As Integer)
If NewRecord = True Then
If Forms!frmmainentry.CaseType = "Murder" Then Me.PersonType.Value =
"Victim"
Me.HomicideNO.SetFocus
Me.PersonType.Enabled = False
ElseIf Forms!frmmainentry.CaseType = "OIS - Fatal" Then
Me.PersonType.Value = "OIS Decedent"
NewRecord.Me.PersonType.Value = "Officer"
ElseIf Forms!frmmainentry.CaseType = "ICD" Then Me.PersonType.Value =
"ICD Decedent"
End If
Else
End If
End Sub