Public Sub SaveSomeFields()
On Error GoTo SavesomeFieldsErr
'========1/10/2011 = This code specific for Forms!ChartNoteGenSx
'===SaveFieldCode is set up from Forms!ChartNoteGenSxWho, under DisableFields Sub
'====Setup SaveFieldsCode
'=====This field is not really a code field on CHANNotes. It acts as a code to determine
'=====which fields are to be save as determined by ChartNoteGenSxWho. This protects staff
' from overwritting doctor changes and visa versa.
'0-NPO, 1-Ride, 2-PreVits, 3-MedCode, 4-ProcCode, 5-ProcCodeA, 6-TypeCode, 7-TypeCodeA
'8-Implants, 9-opUR, 10-opUL, 11-opLR, 12-opLL, 13-StFinCode, 14-VitalsCode, 15-SutPak
'16-POInstCode, 17-MedInt, 18-GasInt, 19-IVMon, 20-Staff, 21-AsstSx, 22-AsstPO
'23-OpNote, 24-PONote, 25-Rx
Dim RS As DAO.Recordset
Dim SavRay() As String
Dim y As Long
Dim strsavefields, Spacer, strTemp As Variant
'Dim strfieldname As Variant
'Dim CNSql As String
Set RS = CurrentDb.OpenRecordset("SELECT * FROM CHANNotes WHERE nID = " & Forms!ChartNoteGenSx!nID, dbOpenDynaset)
strsavefields = Null
'DBEngine.Idle (dbFreeLocks)
'Dim frmCN As Form
Dim frmCSx As Form
Set frmCSx = Forms!ChartNoteGenSx
'---Check to see if ChartNote is open, if not open it
' If IsLoaded("ChartNote") <> True Then
' DoCmd.OpenForm "ChartNote", , , "nid =" & Forms!ChartNoteGenSx.nID, , acHidden
' Set frmCN = Forms!ChartNote
' End If
If IsNull(frmCSx!SaveFieldsCode) Then
frmCSx!SaveFieldsCode = "x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x"
GoTo SavesomeFieldsExit
End If
'0-NPO, 1-Ride, 2-PreVits, 3-MedCode, 4-ProcCode, 5-ProcCodeA, 6-TypeCode, 7-TypeCodeA
'8-Implants, 9-opUR, 10-opUL, 11-opLR, 12-opLL, 13-StFinCode, 14-VitalsCode, 15-SutPak
'16-POInstCode, 17-MedInt, 18-GasInt, 19-IVMon, 20-Staff, 21-AsstSx, 22-AsstPO
'23-OpNote, 24-PONote, 25-Rx
'=====For testing Delete after test
'"1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-2-x-x-x-x-x-x-x-x-x"
' frmCSx.SaveFieldsCode = "x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x"
SavRay() = Split(frmCSx!SaveFieldsCode, "-")
With RS
.Edit
If SavRay(0) <> "x" Then 'anything other than 'x'=Save field otherwise ignore changes
If DLookup("NPOStatus", "CHANNotesTblNPOStatus") <> frmCSx!NPOStatus Then
'frmCN!NPOStatus = frmCSx!NPOStatus '==Only Save if date is current
!NPO = frmCSx!NPOStatus
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "NPO = '" & frmCSx!NPOStatus & "'"
End If
End If
If SavRay(1) <> "x" Then
'frmCN!Ride = frmCSx!Ride
!Ride = frmCSx!Ride
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "Ride = '" & frmCSx!Ride & "'"
End If
If SavRay(2) <> "x" Then
'frmCN!PreVitCode = frmCSx!PreVitCode
!Previtecode = frmCSx!PreVitCode
'GoSub routineSpacer
'strTemp = FixEscapesInSql(frmCSx!PreVitCode)
'MsgBox strTemp
'strsavefields = strsavefields & Spacer & "PreVitCode = '" & strTemp & "' "
End If
If SavRay(3) <> "x" Then
!MedCode = frmCSx!MedCode
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "MedCode = '" & FixEscapesInSql(frmCSx!MedCode) & "'"
'strsavefields = strsavefields & Spacer & "MedCode = '" & FixEscapesInSql(tstring) & "'"
End If
If SavRay(4) <> "x" Then
'frmCN!ProcCode = frmCSx!ProcCode
!ProcCode = frmCSx!ProcCode
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "ProcCode = '" & frmCSx!ProcCode & "' "
End If
If SavRay(5) <> "x" Then
'frmCN!ProcCodeA = frmCSx!ProcCodeA
!ProcCodeA = frmCSx!ProcCodeA
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "ProcCodeA = '" & frmCSx!ProcCodeA & "' "
End If
If SavRay(6) <> "x" Then
!TypeCode = frmCSx!TypeCode
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "TypeCode = '" & frmCSx!TypeCode & "' "
End If
If SavRay(7) <> "x" Then
!TypeCodeA = frmCSx!TypeCodeA
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "TypeCodeA = '" & frmCSx!TypeCodeA & "' "
End If
If SavRay(8) <> "x" Then
!Implants = frmCSx!Implants
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "Implants = '" & frmCSx!Implants & "' "
End If
If SavRay(9) <> "x" Then
If Not IsNull(frmCSx!opUR) Then !opUR = FixEscapesInSql(frmCSx!opUR)
'GoSub routineSpacer
'If Not IsNull(frmCSx!opUR) Then strsavefields = strsavefields & Spacer & "opUR = '" & FixEscapesInSql(frmCSx!opUR) & "' "
End If
If SavRay(10) <> "x" Then
If Not IsNull(frmCSx!opUL) Then !opUL = FixEscapesInSql(frmCSx!opUL)
'GoSub routineSpacer
'If Not IsNull(frmCSx!opUL) Then strsavefields = strsavefields & Spacer & "opUL = '" & FixEscapesInSql(frmCSx!opUL) & "' "
End If
'MsgBox strsavefields
'GoSub SaveCurrentString
'strsavefields = Null
'MsgBox "Saved 1-10"
If SavRay(11) <> "x" Then
If Not IsNull(frmCSx!opLR) Then !opLR = FixEscapesInSql(frmCSx!opLR)
'GoSub routineSpacer
'If Not IsNull(frmCSx!opLR) Then strsavefields = strsavefields & Spacer & "opLR = '" & FixEscapesInSql(frmCSx!opLR) & "' "
End If
If SavRay(12) <> "x" Then
If Not IsNull(frmCSx!opLL) Then !opLL = FixEscapesInSql(frmCSx!opLL)
'GoSub routineSpacer
'If Not IsNull(frmCSx!opLL) Then strsavefields = strsavefields & Spacer & "opLL = '" & FixEscapesInSql(frmCSx!opLL) & "' "
End If
If SavRay(13) <> "x" Then
!StartFinCode = frmCSx!StartFinCode
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "StartFinCode = '" & frmCSx!StartFinCode & "' "
End If
If SavRay(14) <> "x" Then
!VitalsCode = frmCSx!VitalsCode
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "VitalsCode = '" & frmCSx!VitalsCode & "' "
End If
If SavRay(15) <> "x" Then
!SutPakCode = frmCSx!SutPakCode
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "SutPakCode = '" & frmCSx!SutPakCode & "' "
End If
If SavRay(16) <> "x" Then
If Not IsNull(frmCSx!POInstCode) Then !POInstCode = FixEscapesInSql(frmCSx!POInstCode)
'GoSub routineSpacer
'If Not IsNull(frmCSx!POInstCode) Then strsavefields = strsavefields & Spacer & "POInstCode = '" & FixEscapesInSql(frmCSx!POInstCode) & "' "
End If
If SavRay(17) <> "x" Then
!MedIntervals = frmCSx!MedIntervals
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "MedIntervals = '" & frmCSx!MedIntervals & "' "
End If
If SavRay(18) <> "x" Then
!GasIntervals = frmCSx!GasIntervals
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "GasIntervals = '" & frmCSx!GasIntervals & "' "
End If
If SavRay(19) <> "x" Then
!IVMonCode = frmCSx!IVMonCode
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "IVMonCode = '" & frmCSx!IVMonCode & "' "
End If
If SavRay(20) <> "x" Then
If Not IsNull(frmCSx!Staff) Then !Staff = FixEscapesInSql(frmCSx!Staff)
'GoSub routineSpacer
'If Not IsNull(frmCSx!Staff) Then strsavefields = strsavefields & Spacer & "Staff = '" & FixEscapesInSql(frmCSx!Staff) & "' "
End If
'GoSub SaveCurrentString
'strsavefields = Null
'MsgBox "Saved 11-20"
If SavRay(21) <> "x" Then
If Not IsNull(frmCSx!AsstSx) Then !AsstSx = FixEscapesInSql(frmCSx!AsstSx)
'GoSub routineSpacer
'If Not IsNull(frmCSx!AsstSx) Then strsavefields = strsavefields & Spacer & "ASxNotes = '" & FixEscapesInSql(frmCSx!AsstSx) & "' "
End If
If SavRay(22) <> "x" Then
If Not IsNull(frmCSx!AsstPO) Then !AsstPO = FixEscapesInSql(frmCSx!AsstPO)
'GoSub routineSpacer
'If Not IsNull(frmCSx!AsstPO) Then strsavefields = strsavefields & Spacer & "AsstPO = '" & FixEscapesInSql(frmCSx!AsstPO) & "' "
End If
'GoSub SaveCurrentString
'strsavefields = Null
'=====================================OPNOTE=====================
'saveray(23) or OpNote is saved later at bottom thru Form ChartNote
If SavRay(23) <> "x" Then
Dim temp As Variant
temp = frmCSx!OpNote
MsgBox temp
If Not IsNull(frmCSx!OpNote) Then !nNote = temp
'------ORIGINAL
'GoSub routineSpacer
'If Not IsNull(frmCSx!OpNote) Then strsavefields = strsavefields & Spacer & "nNote = '" & FixEscapesInSql(frmCSx!OpNote) & "' "
'MsgBox Len(frmCSx!OpNote)
'------ORIGINAL
End If
'GoSub SaveCurrentString
'strsavefields = Null
'=================================================================
If SavRay(24) <> "x" Then
If Not IsNull(frmCSx!TxSumNote) Then !TxSumNote = FixEscapesInSql(frmCSx!TxSumNote)
'GoSub routineSpacer
'If Not IsNull(frmCSx!TxSumNote) Then strsavefields = strsavefields & Spacer & "TxSumNote = '" & FixEscapesInSql(frmCSx!TxSumNote) & "' "
End If
If SavRay(25) <> "x" Then
If Not IsNull(frmCSx!Rx) Then !Rx = FixEscapesInSql(frmCSx!Rx)
'GoSub routineSpacer
'If Not IsNull(frmCSx!Rx) Then strsavefields = strsavefields & Spacer & "Rx = '" & FixEscapesInSql(frmCSx!Rx) & "' "
End If
If Not IsNull(frmCSx.DOS) Then
!DOS = frmCSx!DOS
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "DOS = #" & frmCSx.DOS & "#"
End If
If Not IsNull(frmCSx!nConsID) Then
!nConsID = frmCSx.nConsID
'GoSub routineSpacer
'strsavefields = strsavefields & Spacer & "nConsID = '" & frmCSx.nConsID & "' "
End If
'GoSub SaveCurrentString
'strsavefields = Null
.Update
.Close
End With
frmCSx!togChg = ""
SavesomeFieldsExit:
DoCmd.Close acForm, "ChartNote"
Set RS = Nothing
DoCmd.SetWarnings True
Exit Sub
SavesomeFieldsErr:
'If Err.Number = "3186" Then
' MsgBox "The field size might have been exceeded. Start a new note." & vbCrLf & vbCrLf & "The note has been save in the patient's file as Backup.txt"
' Dim strPathFileName As String
' strPathFileName = DLookup("PDocs", "CHANLinkPaths") & "\" & Forms!ChartMain!nPID & "\DocNoteBackup.txt"
' Call WriteToTxtFile(frmCSx!OpNote, strPathFileName)
'Else
MsgBox "ChartPublic-SavesomeFields: " & Err.Number & " - " & Err.Description
'End If
Resume SavesomeFieldsExit
routineSpacer:
If IsNull(strsavefields) Then
Spacer = Null
Else
Spacer = ", " & vbCrLf
End If
Return
SaveCurrentString:
'MsgBox "Fields to save: " & vbCrLf & strsavefields
If strsavefields <> "" Then
'======OLD
'CNSql = "UPDATE CHANNotes SET " & strsavefields & _
"WHERE nID = " & Forms!ChartNoteGenSx.nID
'DoCmd.SetWarnings False
'MsgBox CNSql
'DoCmd.RunSQL CNSql
End If
Return
End Sub