Quick question. From a dashboard, I open one of a number of forms. On each form is a "Return to Main Menu" button. The button runs a macro which is simply a CloseWindow (ObjectType=Form). I want to use one macro regardless of which form is open. In earlier versions of Access I thought I could get away with leaving the objectname blank, but I'm now in 2007/10 and that doesn't seem to work. I tried setting the ObjectName "=[screen.activeform.name]" but that doesn't work. What is the correct/best way to create a generic close?
I knew I could close the form by passing the explicit FormName (either as Macro or a VBA). I was trying to avoid having to code each button with the name of the form it's on. Essentially I was trying to do the same as clicking the "X" in the upper-right corner of the form. I know it's probably better to use the explicit method, but in this case it would cleaner to be completely generic. I thought I could just enumerate the FormName with "screen.activeform.name" or something similar, but that syntax doesn't work.
I've got a module
Public Function CloseCurrentForm()
DoCmd.Close acForm, Me.Name, acSaveNo
and I could drop everything except the DoCmd.Close.
But now my problem is that when I go to the button OnClick event, I can't find the module or event. Double clicking the [Event Procedure] option merely creates a new button specific function.
For everyone, access didn't like this use of Me.Name.
I tried DoCmd.Close acForm,, acSaveNo and it didn't like that either.
DoCmd.Close by itself did work. So I was officially done.
But just out of curiosity, I also went back to the original non-working macro's that used CloseWindow with no arguments; deleted them and then recreated them; and voila they now work. Must have been something in the moving of the db from 2003 to 2010.
Thanks to all.