D
DubboPete
Hi all,
I have this bit of code to check for empty fields in a record before closing
the form, and prompts users to complete the record to avoid it being
deleted.
It should (during testing) check the [focusobjective] field, and kick in
from there, because I am intentionally leaving it blank (and all other field
apart from [focus].) For some reason when I click close it jumps to field
[strategies]. I then have to click close again before coming up with the
error message box?
I know it's gonna be simple.... but can someone run a different set of eyes
over it to check out why?
tia
DubboPete
<code>
Private Sub Form_Close()
' SERIES OF CHECKS
' To test the data before exiting
' the recordset, to ensure data
' integrity
If Not IsNull(Me![Focus]) Then
If IsNull(Me![FocusObjective]) Or IsNull(Me![Strategies]) Or
IsNull(Me![Indicators]) Or IsNull(Me![When]) Then
If MsgBox("Some fields have not been completed." & vbCrLf &
"Quitting now would delete this focus completely." & vbCrLf & "Are you sure
you want to close?", vbYesNo) = vbNo Then
If IsNull(Me![FocusObjective]) Then
MsgBox "Please provide a valid focus objective before
proceeding", vbInformation
Me![FocusObjective].SetFocus
Exit Sub
End If
If IsNull(Me![Strategies]) Then
MsgBox "Please provide a valid strategy before proceeding",
vbInformation
Me![Strategies].SetFocus
Exit Sub
End If
If IsNull(Me![Indicators]) Then
MsgBox "Please provide a valid Focus Objective before
proceeding", vbInformation
Me![FocusObjective].SetFocus
Exit Sub
End If
If IsNull(Me![When]) Then
MsgBox "Please provide a valid expected completion date
before proceeding", vbInformation
Me![When].SetFocus
Exit Sub
End If
Else
DoCmd.SetWarnings False
DoCmd.OpenQuery "QryDelBadFocus"
DoCmd.SetWarnings True
End If
End If
End If
End Sub
</code>
I have this bit of code to check for empty fields in a record before closing
the form, and prompts users to complete the record to avoid it being
deleted.
It should (during testing) check the [focusobjective] field, and kick in
from there, because I am intentionally leaving it blank (and all other field
apart from [focus].) For some reason when I click close it jumps to field
[strategies]. I then have to click close again before coming up with the
error message box?
I know it's gonna be simple.... but can someone run a different set of eyes
over it to check out why?
tia
DubboPete
<code>
Private Sub Form_Close()
' SERIES OF CHECKS
' To test the data before exiting
' the recordset, to ensure data
' integrity
If Not IsNull(Me![Focus]) Then
If IsNull(Me![FocusObjective]) Or IsNull(Me![Strategies]) Or
IsNull(Me![Indicators]) Or IsNull(Me![When]) Then
If MsgBox("Some fields have not been completed." & vbCrLf &
"Quitting now would delete this focus completely." & vbCrLf & "Are you sure
you want to close?", vbYesNo) = vbNo Then
If IsNull(Me![FocusObjective]) Then
MsgBox "Please provide a valid focus objective before
proceeding", vbInformation
Me![FocusObjective].SetFocus
Exit Sub
End If
If IsNull(Me![Strategies]) Then
MsgBox "Please provide a valid strategy before proceeding",
vbInformation
Me![Strategies].SetFocus
Exit Sub
End If
If IsNull(Me![Indicators]) Then
MsgBox "Please provide a valid Focus Objective before
proceeding", vbInformation
Me![FocusObjective].SetFocus
Exit Sub
End If
If IsNull(Me![When]) Then
MsgBox "Please provide a valid expected completion date
before proceeding", vbInformation
Me![When].SetFocus
Exit Sub
End If
Else
DoCmd.SetWarnings False
DoCmd.OpenQuery "QryDelBadFocus"
DoCmd.SetWarnings True
End If
End If
End If
End Sub
</code>