Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

F5 doesn't work correctly

Status
Not open for further replies.

EllieFant

MIS
May 15, 2001
513
0
0
US
I am creating a new database. I put a button on the form with the code:

docmd.quit

When I view this code in the code window, put my mouse in that function and press F5 I get the macro window pop up. It doesn't execute the function. Any idea why?

Thanks!
Lena
 
I guess my question is why would you think it would do something?

You are on selecting a form's event procedure not a subroutine in a standard module.
 
if you want to call a form event from the immediate window or another module. Then you need something like

form_FrmName.CtrlName_click

That calls the click event on FrmName for Control CtrlName.
 
Why would I think it would do anything? Cause it is suppose too. It always has in the past.

If I have the following code on a form and in a module:

Private Sub QuitThisDatabase()

DoCmd.Quit

End Sub

pressing F5 in the module (with the cursor within the sub) will cause the application to quit. If I put the cursor in the same place in the code on the form and press F5 the box pops up asking me which macro I want to run.

This has never happened before. It has always ran the sub and performed whatever action it was programed to do (in this case quit the application) or given me an error letting me know there was something written wrong in the code.

I am trying to figure out why this has stopped functioning the way it always has in the past.

Lena
 
As I clearly stated it never stopped functioning. It only functioned when calling from a standard module, it never works when calling from a class module such as a form's, report's, or other class module. This is logical and expected behavior.
 
I guess we will just agree to disagree because what I am trying to do did work at one time. I am not the only one that has noticed the difficulty in trying to debug the form's code. Oh well...I will find the answer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top