Results 1 to 8 of 8
  1. #1
    xfp39024 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2012
    Posts
    15

    Start up MS-Access from vb and bypass the autoexec macro

    Hi -- I know that I can startup MS-Access manually and bypass the startup options, including any macro that is set to run automatically, by holding the Shift key down when launching the application. What I need to know is how to do this in a vb program. I have:



    Code:
        Public Sub AccessStuff()
            Dim myaccess As New Access.Application
            myaccess.OpenCurrentDatabase("\\torfs006\slsops_repts\_\RS Dev\SOP\SOP.MDB")
            Dim db = myaccess.CurrentDb()
        End Sub
    which works nicely and opens the database just fine. However, this mdb has a startup macro defined in it. I can't hold down the Shift key since I'm doing this from a program. In this case, how can I bypass the startup macro?

  2. #2
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    WOW. interesting question!

    there is code out there to disable the shift bypass on a permanent basis, until it is turned on again via a developer. I wonder if that could help you in this situation? obviously you can't do that either, through code.

    but another option, if you have a lot of these scenarios, is to always run your startup macro, but only run a command where you set a pointer to a visual basic subroutine that runs another "conditional" macro that mirrors the autoexec macro you have now.

    that way, you can set rules like this without having to run into impossible scenarios like what you're currently seeing. what would be the easiest here, as I see it, is to have the condition that you can satisfy during the PREVIOUS session when the database is opened. this conditional therefore, would be stored inside that database as a boolean indicator that can be referenced with the startup routine.

  3. #3
    xfp39024 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2012
    Posts
    15
    If I can permanently enable the shift-bypass, as you suggest, that would do it. do you have a link to code that does that? Is it, perhaps, a registry setting? A for the other option, since the program will run through many, many mdbs that I would not open otherwise, I can't think of a practical way to implement the suggestion, though it is a good one.

  4. #4
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    you say ENABLE the shift? I thought what you wanted was to DISABLE it? and no, it's not a registry setting. I believe it's a property of the mdb files...

    let me look though...

  5. #5
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    yeah, see, according to ms it's a property of the file:

    http://support.microsoft.com/kb/826765

    being a registry setting makes no sense at all anyway, as registry settings and keys are more or less geared towards manipulating top-level operations with programs themselves. like initializations.

  6. #6
    xfp39024 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2012
    Posts
    15
    I want to disable the autorun stuff, hence make access think that I hit shift when I launch it.

  7. #7
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    wow, I'm sorry. where is my brain!? must be a bad day today.

    bottom line - I don't think you can do it with visual basic coding. I think you have to use a ghost macro, or another method.

    I can't think of any other methods at this point. sorry! but I wish you luck!

  8. #8
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    The shift bypass is on the code repository of this site.

    https://www.accessforums.net/code-re...pass-7549.html

    I assume you would put the code in the file you are opening, if you do this the MDB you are opening will always bypass the shift key... So might not be a usefull tool.. but who knows.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. bypass parameter
    By Epona in forum Queries
    Replies: 1
    Last Post: 06-09-2012, 05:57 PM
  2. Help Stopping AutoExec Macro
    By drewetzel in forum Access
    Replies: 2
    Last Post: 10-03-2011, 10:51 AM
  3. Replies: 2
    Last Post: 06-20-2011, 09:20 AM
  4. Out of control loop in autoexec macro
    By accessnewbie in forum Programming
    Replies: 2
    Last Post: 08-19-2010, 04:31 PM
  5. Using parameter in autoexec macro
    By lchurch in forum Queries
    Replies: 0
    Last Post: 03-04-2009, 06:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums