views:

176

answers:

2

Hi

I've inherited a Access database that is used to import some data in SQL. The MDB opens with a form, in a modal mode: no Access menubar or buttons are visible. I can view the tables with content by using the Visual Studio 'Data Connection' tool, but I cannot see the module's code.

I've looked at this question here, but the answers there aren't really what I need. Is there a way to either force the form to close (and access the modules) or to extract the VBA code ?

[EDIT] I am using Access 2007, not sure what the original developer used.

+2  A: 

Hold down the shift key when you open the database. This will prevent it from loading the automatic script it's running and allow you to gain access to the tables, queries, and VBA scripts.

Michael Todd
Your answer assumes that the startup bypass key has not been disabled. It's easy enough to reverse, though.
David-W-Fenton
I'm unfamiliar with that. How does one enable the startup bypass key if it's been disabled?
Michael Todd
Thanks. I've tried this with no success. On 'startup' Access throws an error 'Action Failed' on RunCode. All I can do is 'Stop all Macros' After I click that nothing happens, only Access's default 'Security warning' bar appears at the top. If I choose 'Enable this content' the form is displayed, hiding all menu bars etc. This all happens with and withour holding the shift key.
edosoft
Sounds like you need to change your Access macro security settings. You don't specify your version of Access, so it's kind of hard to explain how to do that.
David-W-Fenton
For information on the startup bypass key, see the Access help file topic for AllowBypassKey (in the VBE, not from the main Access window). Code is offered there to enable/disable the startup bypass key. For a discussion of one of the minor weaknesses of the code given in the help file and a somewhat more robust solution (not applicable to ACCDB format), see http://www.mvps.org/access/general/gen0040.htm .
David-W-Fenton
Thanks very much for the information. I've been using Access since Access 95 yet I was unaware of that switch.
Michael Todd
A: 

This is a rather long addendum to, or comment on, Michael Todd's reply in response to edosoft's comment.

Rather than choosing to enable the content, check the start-up options (either (file->options->current database->display form) or (tools->start up->display form)) and remove the name of the form, having taken a note, and ensure that Allow Full Menus (same page) is ticked. You may also like to press Alt+F11 to display code, and check that for start-up code, finally, see if there is an AutoRun macro and rename it.

EDIT re Comments

You do not have to open an mdb to change the start-up form, for example, code such as this could be run from another mdb using the full name and path of the mdb you wish to change.

Sub SetStartForm(DBFile As String)
Dim prp As Object
Dim db As Database

Const PROPERTY_NOT_FOUND As Integer = 3270

    Set db = OpenDatabase(DBFile)

    db.Properties("StartupForm") = "(none)" 

    If Err.Number > 0 Then
        If Err.Number = PROPERTY_NOT_FOUND Then
            '' Create the new property, but this is not relevant in this case
         End If
    End If

    db.Close
    Set db = Nothing
    Set prp = Nothing
End Sub
Remou
The problem is the form (or code) hides all menu bars, so File-> Options is unavailable. I have tried ALT+F11 without success :(
edosoft
Are you saying that the form appears even when you hold the shift key down until the database has fully opened and you do not choose to enable content?
Remou
@remou Yes that is what I am saying
edosoft
Have you considered AllowBypassKey as per comments on @Michael Todd's answer? Does Alt+F11 open the code window for you?
Remou
I have added a note on removing a startup form.
Remou