Running a function when database is opened

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!
With lots of help from this forum, I now have code working to link to a
selected backend database. I want this function run when the frontend
database is openned. The code is a function within a module. How do I run the
function upon startup. I was opening a form in the database startup which
would run the function. The problem is that after the function is run, it
won't let me close the form using docmd acForm me.name. What is the most
efficient way.
 
You could put this code in your form's Open event:
Call NameOfFunction
Cancel = True

or,

You could use the autoexec macro to call the function. Look for autoexec
macros in the Help file.
 
The "Cancel = True" statment didn't work. No errors, but the form is still
open. By the way, if I use the "DoCmd.Close acForm, Me.Name" statement, I get
the following error ...

"This action can't be carried out while processing a form or report event"

I don't know if this helps. Thanks!

-Howard

PC Datasheet said:
You could put this code in your form's Open event:
Call NameOfFunction
Cancel = True

or,

You could use the autoexec macro to call the function. Look for autoexec
macros in the Help file.
 
The "Cancel = True" statment will work if coded correctly! Post all your
code in the form's open event.

Where are you using "DoCmd.Close acForm, Me.Name" ? Post all your code there
too.

Steve
PC Datasheet


Howard said:
The "Cancel = True" statment didn't work. No errors, but the form is still
open. By the way, if I use the "DoCmd.Close acForm, Me.Name" statement, I get
the following error ...

"This action can't be carried out while processing a form or report event"

I don't know if this helps. Thanks!

-Howard
 
Back
Top