Running a function when database is opened

H

Howard

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.
 
P

PC Datasheet

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.
 
H

Howard

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.
 
P

PC Datasheet

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top