Why does the code work on a form, but not the switchboard?

K

kbeaton

I added an option on my switchboard menu gave it a title, told it to
Run Code, and gave it the value "=mod_Quit()" (without the quotes)
I get an error message that says "There was an error executing the
command"
I also tried just "mod_Quit()"

I created a new blank form and added a button with the onclick value of
"=mod_Quit()", and it works fine. Closes my database just fine.

Can I not user the "mod_Quit()" from the Switchboard? If so how?

Code for "=mod_Quit()"
++++++++++++++++++++++++++++
Function mod_Quit()
On Error GoTo mod_Quit_Err
DoCmd.Quit acSave
mod_Quit_Exit:
Exit Function
mod_Quit_Err:
MsgBox Error$
Resume mod_Quit_Exit
End Function
++++++++++++++++++++++

I tried this too
++++++++++++++++++++++
Function mod_Quit()
DoCmd.Quit acSave
End Function
++++++++++++++++++++++

Neither of these options work.
What am I missing here.
What is unique about the Switchboard?

Thanks

Kelvin
 
F

fredg

I added an option on my switchboard menu gave it a title, told it to
Run Code, and gave it the value "=mod_Quit()" (without the quotes)
I get an error message that says "There was an error executing the
command"
I also tried just "mod_Quit()"

I created a new blank form and added a button with the onclick value of
"=mod_Quit()", and it works fine. Closes my database just fine.

Can I not user the "mod_Quit()" from the Switchboard? If so how?

Code for "=mod_Quit()"
++++++++++++++++++++++++++++
Function mod_Quit()
On Error GoTo mod_Quit_Err
DoCmd.Quit acSave
mod_Quit_Exit:
Exit Function
mod_Quit_Err:
MsgBox Error$
Resume mod_Quit_Exit
End Function
++++++++++++++++++++++

I tried this too
++++++++++++++++++++++
Function mod_Quit()
DoCmd.Quit acSave
End Function
++++++++++++++++++++++

Neither of these options work.
What am I missing here.
What is unique about the Switchboard?

Thanks

Kelvin

The name of the function to write in the dialog box is
mod_Quit
not mod_Quit() or = mod_Quit()

Why a function? A function is used to return a value.

A sub routine should do very nicely.

Sub mod_Quit()
DoCmd.Quit
End Sub

The fact that the Switchboard dialog box asks for a Function name
doesn't mean you can't enter a Sub routine name.
 
K

kbeaton

Thanks for the help!!

Kelvin

The name of the function to write in the dialog box is
mod_Quit
not mod_Quit() or = mod_Quit()

Why a function? A function is used to return a value.

A sub routine should do very nicely.

Sub mod_Quit()
DoCmd.Quit
End Sub

The fact that the Switchboard dialog box asks for a Function name
doesn't mean you can't enter a Sub routine name.
 

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