mloucel
Member
- Local time
- Yesterday, 20:37
- Joined
- Aug 5, 2020
- Messages
- 256
Hello ALL, I have a SUB, when I close a form that checks if there are any fields changed, if no field is changed then UNDO and close the form, if not save the fields, but for a reason I cannot comprehend when I finish checking the fields and my variable is set to "TRUE", comes back to my SUB and now the Variable is ONCE AGAIN set to "F" I've tried different possibilities, changing the names of the sub and the variable, setting the variable to boolean, placing msgbox all over the place to see where is changing and I cannot find why.
Any help will be appreciated, Thanks...
Any help will be appreciated, Thanks...
Code:
Private Sub SaveNCloseBtn_Click()
Dim ChkFlds As String ' I Tried changing this to boolean same result
ChckFlds = "F"
If (IsNull(UserName) Or IsNull(UserLogin) Or IsNull(UserPassw)) Then
DoCmd.Close acForm, Me.Name, acSaveNo
Exit Sub
End If
OfficeID = TempVars!TOfficeID2
Call CheckingFields
If Form.Dirty = True And ChckFlds = "F" Then
MsgBox "Here again " & "Check: " & ChckFlds
Form.Dirty = False
Else
MsgBox "Close Form"
Me.Undo
'DoCmd.RunCommand acCmdUndo
DoCmd.Close acForm, Me.Name, acSaveNo
End If
End Sub
Function CheckingFields()
MsgBox UserLogin.Value & " OLD VALUE: " & UserLogin.OldValue
If UserName.OldValue = UserName.Value And UserLogin.OldValue = UserLogin.Value And _
UserPassw.OldValue = UserPassw.Value And Level.OldValue = Level.Value Then ChckFlds = "True"
If ChckFlds = "True" Then MsgBox "Now CheckFields is: " & ChckFlds
' when this goes back to SaveNCloseBtn DAMN
' ChckFlds is again F... WHY?????
End Function