Results 1 to 8 of 8
  1. #1
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419

    Auto-run Access VBA modules

    Hello -

    I would like to have access when someone opens it to automatically run a macro or program module. I read is AutoExec macro,



    However I put the function name to runcode it doesn’t work.

    Please advise.

    Thank you

  2. #2
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    The alternative to an autoexec is to have access open a form on start up and run your code from that.
    The form can be hidden to prevent users from interfering with it.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    Can you show me with examples the two ways. I use the autoExec, it doesn’t work on me and is having an issue.

  4. #4
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Have look here https://btabdevelopment.com/how-to-set-a-startup-form/ this is for earlier versions.
    The same options are available in the current database tab under File¬Options menu. "Display Form" will display a form on start up.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    I think I like the AutoExec method more because it’s a macro that when Access is open is runs the code.

    Doesn’t need any form to run it.

  6. #6
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    So what have you tried in an Autoexec that doesn't work ? Can you post a screen shot?

    The Form can have many advantages, you can use it to store hidden data about the current user, when they opened the app and give them command buttons to access the rest of the system..

    Here's the link for newer access https://btabdevelopment.com/how-to-s...m-access-2010/
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    Here's a barebones working example.

  8. #8
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    Thanks I just tried it a couple of times and figured it out. In the Macros I just change the name to AutoExec and in the designed view I selected RunCode and function name as functionname(). And in the module I have it as public function functionname()

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

Similar Threads

  1. When to use standard modules vs. class modules
    By Access_Novice in forum Programming
    Replies: 7
    Last Post: 01-03-2016, 10:47 PM
  2. Replies: 2
    Last Post: 06-27-2014, 11:53 AM
  3. Replies: 2
    Last Post: 01-08-2013, 03:28 PM
  4. Update Access Modules
    By Othello911 in forum Access
    Replies: 0
    Last Post: 01-06-2009, 08:39 AM
  5. update access modules
    By wallen in forum Programming
    Replies: 0
    Last Post: 01-06-2009, 08:22 AM

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