Hi Brain,
This is one way to handle it, I guess, that I don't know how well it will
work with your setup and you may not like the effect it has on your
application generally speaking.
I have the following in my code on the form's before update event:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_BeforeUpdate
If Me.Dirty Then
If MsgBox("Data Has been modified! Do you want to save?", vbYesNo +
vbQuestion, _
"Save Record") = vbNo Then
Me.Undo
End If
End If
Exit_BeforeUpdate:
Exit Sub
Err_BeforeUpdate:
MsgBox Err.Number & " " & Err.Description
Resume Exit_BeforeUpdate
End Sub
What that does is make someone confirm any edits/saves before they leave a
record by, I think, any means. That means if they try to navigate to a
different record, close the form, or close the application a message box will
pop asking if they want to save changes.
You may not want that to happen all the time, but for me, making people
aware that they are changing a record or NOT changing it is worth an extra
click.
Hope that helps,
CW
> I made all my forms modal to prevent a problem when shutting down the app,
> but I know there is a way to get past it. Scenario (much simplified):
[quoted text clipped - 21 lines]
> the completeness-checking code attempts to place the focus on the control on
> Form2 that must be completed?
Brian - 28 Nov 2006 23:28 GMT
I already do this and much more. In fact, I analyze each required
control/field and generate a custom message indicating which control is
incomplete, cancel the current action and return the focus to the control
that requires input.
This work well as long as the form that has the incomplete data has the
focus when the user attempts to close the form. This pretty much requires
modal forms. However, I now want to make the app a little more flexible and
allow the user to go set up a vendor, for instance, while in the middle of
creating the contract and he discovers he needs a new vendor - without
cancelling the partial record already input (and I certainly do not want to
allow the save of an incomplete record, as it will likely never get completed
and wreak havoc with reporting output ever after!)
If the user minimizes Form2 having an unsaved half a contract on it, goes
over to Form3 to creates his vendor, and then forgets to go back to complete
the contract on Form2 and instead attempts to close the program from the main
menu, he correctly gets the message from the code on Form1 indicating that
the information is incomplete.
However, in this scenario, the code on Form1 then attempts to move the focus
to the control bound to the data that needs to be completed, but since Form2
does not have the focus, it generates an error.
What I need is a way for the code on Form2 to cancel the action called for
(DoCmd.Quit) on Form1 (the main menu from whence the user is attempting to
close the application) and get the focus back to Form2 before setting the
focus to a particular control on Form2.
> Hi Brain,
>
[quoted text clipped - 62 lines]
> > the completeness-checking code attempts to place the focus on the control on
> > Form2 that must be completed?
I handled a situation like that by hiding Form1 while Form2 was open,
and then the "Close" button unhid Form1.
HTH,
Chris
> I made all my forms modal to prevent a problem when shutting down the app,
> but I know there is a way to get past it. Scenario (much simplified):
[quoted text clipped - 21 lines]
> the completeness-checking code attempts to place the focus on the control on
> Form2 that must be completed?
Brian - 28 Nov 2006 23:05 GMT
Except that I have many more forms than just Form1 & Form2. Form1 is my main
menu, and I want to allow users to get back to the menu so they can get to
Form3, Form4, etc. from there while Form2 is still open, even if Form2 is
still in the middle of an incomplete record. Otherwise, I might as well just
keep my forms modal the way I have it now, which offers perfect protection
but less flexibility for the user.
> I handled a situation like that by hiding Form1 while Form2 was open,
> and then the "Close" button unhid Form1.
[quoted text clipped - 27 lines]
> > the completeness-checking code attempts to place the focus on the control on
> > Form2 that must be completed?