Created
December 3, 2015 16:21
-
-
Save kissmygritts/56bc21f89f010b9c6a10 to your computer and use it in GitHub Desktop.
Record submission for data entry form.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim msg As Integer, ndow As Integer, encounter As Integer | |
Dim sqlstring As String, capturesql As String, biometricsql As String, barcode As String | |
Dim animalsql As String | |
Dim ars As DAO.Recordset, crs As DAO.Recordset, recaprs As DAO.Recordset | |
actform = Me.Name | |
animalsql = "SELECT * FROM data_Animal ORDER BY AnimalKey;" | |
capturesql = "SELECT EncounterID, AnimalKey, CapDate, Status, capE, capN, CapMtnRange, CapHuntUnit, CapLocDesc, " & _ | |
"Street, City, Zip, relE, relN, RelMtnRange, RelHuntUnit, RelLocDesc, Recapture, " & _ | |
"Relocated, ArrTime, TrTime, AmbTemp, Weather, Wind, Comments, Biologist, Biometrics, " & _ | |
"Vitals, Samples, Medications, Injury, Immobilization, Mortality, DateEntered, DEuser " & _ | |
"FROM data_Capture " & _ | |
"ORDER BY EncounterID;" | |
biometricsql = "SELECT EncounterID, Age, YearsOld, PermIncisor, BCS, Weight, w_units, NeckSize, ns_units, " & _ | |
"ChestGirth, cg_units, Jaw, j_units, HindLeg, hl_units FROM data_Biometric;" | |
recapsql = "SELECT AnimalKey FROM data_Animal WHERE data_Animal.ndowID = " & Me.ndowID & ";" | |
Set ars = CurrentDb.OpenRecordset(animalsql) | |
Set crs = CurrentDb.OpenRecordset(capturesql) | |
ars.MoveFirst: crs.MoveFirst | |
If (IsNull(Me.ndowID) Or IsNull(Me.CapDate) Or IsNull(Me.Species) Or IsNull(Me.Status)) Then | |
MsgBox "Please enter required data. (Wildlife Health Number, Capture Date, Species and Status)", 48, "Required Fields Not Filled!" | |
Me.CapDate.SetFocus | |
Exit Sub | |
End If | |
If (IsNull(Me.CapMtnRange) And IsNull(Me.CapHuntUnit) And IsNull(Me.CapLocDesc) And (IsNull(Me.capE) Or IsNull(Me.capN))) = True Then | |
MsgBox "Location information is required. Please enter information into at least one location field. If using UTM, Easting and Northing is required.", 48, "Location Required!" | |
Me.capE.SetFocus | |
Exit Sub | |
End If | |
If (IsNull(Me.L_etColor) And IsNull(Me.L_etNum) And IsNull(Me.R_etColor) And IsNull(Me.R_etNum) And IsNull(Me.TempID)) Then | |
msg = MsgBox("Mark information is empty. We strongly encourage including marks or IDs be entered. Are you sure you want to continue without Identification information?", 4 + 32, "No Identification!") | |
If msg <> 6 Then | |
Exit Sub | |
Else | |
If Me.Relocated = -1 Then | |
If (IsNull(Me.RelMtnRange) And IsNull(Me.RelHuntUnit) And IsNull(Me.RelLocDesc) And (IsNull(Me.relE) Or IsNull(Me.relN))) Then | |
MsgBox "Relocation is checked but no Release Location data is entered. Either uncheck Relocation or add Release Location data. If using UTM, Easting and Northing is required.", 48, "Release Location!" | |
Exit Sub | |
End If | |
End If | |
If Me.Biometrics = -1 Then | |
If (IsNull(Me.Age) And IsNull(Me.YearsOld) And IsNull(Me.Sex) And IsNull(Me.Weight) And IsNull(Me.BCS) And IsNull(Me.NeckSize) And IsNull(Me.Jaw) And IsNull(Me.ChestGirth) And IsNull(Me.HindLeg)) = True Then | |
MsgBox "You've checked that Biometric data was recorded for this animal. Enter Biometric data or uncheck biometric box.", 48, "Biometric Required!" | |
Me.Age.SetFocus | |
Exit Sub | |
End If | |
End If | |
If Me.Vitals = -1 Then | |
If (IsNull(Me.Time1) And IsNull(Me.Tr1) And IsNull(Me.Time2) And IsNull(Me.Tr2) And IsNull(Me.HR1)) = True Then | |
MsgBox "You've checked that Vitals data was recorded for this animal. Enter Vitals data or uncheck Vitals box.", 48, "Vitals Required!" | |
Me.Time1.SetFocus | |
Exit Sub | |
End If | |
End If | |
If Me.Injury = -1 Then | |
If (IsNull(Me.LegCheck) And IsNull(Me.EarCheck) And IsNull(Me.EyeCheck) And IsNull(Me.TesticlesCheck) And IsNull(Me.PregCheck) And IsNull(Me.OtherInjury)) = True Then | |
MsgBox "You've checked that Injury data was recorded for this animal. Enter Injury data or uncheck Injury box.", 48, "Injury Required!" | |
Me.LegCheck.SetFocus | |
Exit Sub | |
End If | |
End If | |
If Me.Medications = -1 Then | |
If (IsNull(Me.BanamineYN) And IsNull(Me.DraxxinYN) And IsNull(Me.E300) And IsNull(Me.BoSeYN) And IsNull(Me.IvomecYN) And IsNull(Me.CatronYN) And IsNull(Me.IVFluidsYN) And IsNull(Me.Azaperone) And IsNull(Me.HaloperidolYN) And IsNull(Me.MidazolamYN) And IsNull(Me.OxygenYN) And IsNull(Me.OtherTRXYN)) = True Then | |
MsgBox "You've checked that Medication data was recorded for this animal. Enter Medication data or uncheck Medication box.", 48, "Medications Required!" | |
Me.BanamineYN.SetFocus | |
Exit Sub | |
End If | |
End If | |
If Me.Samples = -1 Then | |
If (IsNull(Me.Blood) And IsNull(Me.Pharyngeal) And IsNull(Me.Nasal) And IsNull(Me.Fecal) And IsNull(Me.Parasite) And IsNull(Me.Hair) And IsNull(Me.Carcass) And IsNull(Me.Head) And IsNull(Me.Lungs) And IsNull(Me.Liver) And IsNull(Me.FFtissue) And IsNull(Me.SwabSinus) And IsNull(Me.Bullae) And IsNull(Me.Bladder) And IsNull(Me.Kidney) And IsNull(Me.SinusTissue) And IsNull(Me.Tonsil) And IsNull(Me.Spleen) And IsNull(Me.Trachea) And IsNull(Me.LymphNode) And IsNull(Me.Muscle) And IsNull(Me.Photo) And IsNull(Me.SampleNotes)) = True Then | |
MsgBox "You've checked that Sample data was recorded for this animal. Enter Sample data or uncheck Samples box.", 48, "Samples Required!" | |
Exit Sub | |
End If | |
End If | |
If Me.Immobilization = -1 Then | |
If (IsNull(Me.Reason) And IsNull(Me.Dart1) And IsNull(Me.DrugDose1) And IsNull(Me.DrugName1) And IsNull(Me.Atipamezole)) = True Then | |
MsgBox "You've checked that Immobilization data was recorded for this animal. Enter Immobilization data or uncheck Immobilization box.", 48, "Immobilization Required!" | |
Exit Sub | |
End If | |
End If | |
If Me.Mortality = -1 Then | |
If IsNull(Me.CauseDeath) Then | |
MsgBox "You've checked that Mortality data was recorded for this animal. Enter Mortality data or uncheck Mortality box.", 48, "Mortality Required!" | |
Exit Sub | |
End If | |
End If | |
End If | |
End If | |
msg = MsgBox("Are you sure the information entered is correct and complete?", 4 + 32, "Save Record?") | |
If msg = 6 Then | |
If Me.Recapture = -1 Then | |
Set recaprs = CurrentDb.OpenRecordset(recapsql) | |
recaprs.MoveFirst | |
ndow = recaprs!AnimalKey | |
recaprs.Close | |
Else | |
Call Procedures.form_to_rs("append", "data_Animal", "frmDataEntry", -1, 0) | |
ars.Requery | |
ars.MoveLast | |
ndow = ars!AnimalKey | |
Debug.Print ars!ndowID, ndow | |
End If | |
Call Procedures.form_to_rs("append", capturesql, "frmDataEntry", ndow, -1) | |
crs.Requery | |
crs.MoveLast | |
encounter = crs!EncounterID | |
Call Procedures.form_to_rs("append", "data_Identification", "frmDataEntry", 0, encounter) | |
If Me.Biometrics = -1 Then | |
Call Procedures.form_to_rs("append", biometricsql, "frmDataEntry", 0, encounter) | |
End If | |
If Me.Vitals = -1 Then | |
Call Procedures.VitalsAppend(encounter) | |
End If | |
If Me.Injury = -1 Then | |
Call Procedures.form_to_rs("append", "data_Injury", "frmDataEntry", 0, encounter) | |
End If | |
If Me.Medications = -1 Then | |
Procedures.MedAppend (encounter) | |
End If | |
If Me.Samples = -1 Then | |
Procedures.SamplesAppend (encounter) | |
Call Procedures.form_to_rs("append", "data_MiscOneMany", "frmDataEntry", 0, encounter) | |
End If | |
' If Me.Immobilization = -1 Then | |
' End If | |
If Mortality = -1 Then | |
Call Procedures.form_to_rs("append", "data_mortality", "frmDataEntry", 0, encounter) | |
End If | |
msg = MsgBox("Data has been submitted for review. You must validate the record before it is used in the database", 64, "New record added!") | |
msg = MsgBox("Would you like to enter Capture Data from the same capture?", 4 + 64, "Enter From Same Capture") | |
If msg = 6 Then | |
For Each ctl In Me.Controls | |
Select Case ctl.ControlType | |
Case acTextBox, acComboBox, acCheckBox | |
If (ctl.Name = "Species" Or ctl.Name = "CapDate" Or ctl.Name = "capE" Or ctl.Name = "capN" Or ctl.Name = "relE" Or ctl.Name = "relN" Or ctl.Name = "CapMtnRange" Or ctl.Name = "RelMtnRange" Or ctl.Name = "Biologist" Or ctl.Name = "CapHuntUnit" Or ctl.Name = "RelHuntUnit" Or ctl.Name = "CapLocDesc" Or ctl.Name = "relLocDesc" Or ctl.Name = "Relocated") Then | |
ctl.Value = ctl.Value | |
Else | |
ctl.Value = Null | |
End If | |
End Select | |
Next | |
Else | |
For Each ctl In Me.Controls | |
Select Case ctl.ControlType | |
Case acTextBox, acComboBox, acCheckBox | |
ctl.Value = Null | |
End Select | |
Next | |
End If | |
Me.CapDate.SetFocus | |
dModifyTagValues.EnableTags (actform), ("biometrics") | |
dModifyTagValues.EnableTags (actform), ("injury") | |
dModifyTagValues.EnableTags (actform), ("Medications") | |
dModifyTagValues.EnableTags (actform), ("Relocated") | |
dModifyTagValues.EnableTags (actform), ("Vitals") | |
dModifyTagValues.MakeVisible (actform), ("Samples") | |
dModifyTagValues.MakeVisible (actform), ("Immobilization") | |
dModifyTagValues.MakeVisible (actform), ("Mortality") | |
End If | |
ars.Close: crs.Close | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment