database event

  • Thread starter Thread starter rudwan
  • Start date Start date
R

rudwan

hellow
usually , we close the database through form or swichboard
but suppose i dont have this swithchboard form , and i
want to run a code before closing my file , such as play
sound or sending message or else ,
how i could do that to enforce this code to be run before
closing database from th edesign menue
 
Rudwan,

If you don't have an actual data form or user form which you want to use
for this purpose, you can put a simple unbound hidden form which will
always be open whenever the application is open. Then you can put your
required code on the Unload event of this form, and this will then be
triggered whenever the database is closed by whatever means.
 
I don't believe that it can be done using 'standard' methods - as far as I'm
aware there is no way of getting at a 'database close' event. I'd probably
go for opening a hidden form as the startup form, and then attach my code to
its close or unload event.
 
ok , then suppose i would like after some times to restore
my form , how i can unhide it ?
 
hi steve
i faced a problem
i create unbound form , make this code
Private Sub Form_Unload(Cancel As Integer)
MsgBox " Good Bye "
DoCmd.Quit
End Sub
but after closing database , it said nothing

then i make it a startup form then hidden it from
properties
then , when i open the databse again , the form become
visible again .
 
Rudwan,

The wat to make this form open invisible is to use a Macro, which is
called AutoExec, with an action OpenForm. Enter the name of the form in
the Form Name argument, and enter Hidden in the Window Mode argument.

Also, if I understand you correctly, there is no need for the DoCmd.Quit
line in your code... the database is already in the process of being
closed at the time the Unload event of the form is being called.
 
Back
Top