David Sullivan wrote:
I have a problem with a database where certain users are closing access (by
clicking on the X in top right-hand corner) instead of using a command
button before they fill in all relevant fields.
Here's one method.
Create a form and call it something simple - I use "frmV" and often use
it to store variables in controls instead of relying on global
variables. In the unload event of this form, have the procedures that
you want to make sure happen when the database app is closed. The trick
is, you want this form to open *hidden* when the database is opened.
There are a couple of ways to accomplish this. I will sometimes have a
splash form that appears on opening of the mdb or simply a starting form
with cancel = true in the on open event.
If you use the latter, put in a
DoCmd.OpenForm "frmV", acNormal, , , , acHidden
and then your cancel = true. If you use a splash form that your users
bring up whenever they click on About This App on a menu item or
something, you can check to see if frm HIdden is open in the on open
event of the form (air code):
Private Sub Form_Open(Cancel As Integer)
dim f as Access.form
dim booFound as boolean
boofound = false
for each f in access.forms
if f.name = "frmV" then 'frmOpen is found and is already open
boofound = true
exit for
end if
Next
if boofound = false then DoCmd.OpenForm "frmV", acNormal, , , , acHidden
End Sub
--
Tim
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto