Results 1 to 2 of 2
  1. #1
    stu_C is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2010
    Posts
    38

    auto run Module

    Hi all
    i have some code that i need to run when the users open up the database but when I put it into a module I dont know how to auto run in on open any ideas?

    I have a form that auto opens so wondered if I could add this into form load but it didnt work

    My Code Below

    Option Compare Database
    Private Const GWL_EXSTYLE = (-20)
    Private Const GWL_STYLE = (-16)
    Private Const WS_MAXIMIZEBOX = &H10000
    Private Const WS_MINIMIZEBOX = &H20000
    Private Const WS_SYSMENU = &H80000
    Private Const HWND_TOP = 0
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_FRAMECHANGED = &H20
    Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
    Private Declare Function SetWindowLong Lib "user32" _


    Alias "SetWindowLongA" (ByVal hwnd As Long, _
    ByVal nIndex As Long, ByVal dwNewLong As Long) _
    As Long
    Private Declare Function GetWindowLong Lib "user32" _
    Alias "GetWindowLongA" (ByVal hwnd As Long, _
    ByVal nIndex As Long) As Long
    Private Declare Function SetWindowPos Lib "user32" _
    (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
    ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
    ByVal cy As Long, ByVal wFlags As Long) As Long

    Sub HideAccessCloseButton()
    Dim lngStyle As Long
    lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
    lngStyle = lngStyle And Not WS_SYSMENU
    Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
    Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_DRAWFRAME)
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Put what you have in a Standard Module and invoke it in the OnLoad event of that first form or maybe the AutoExec macro if you want.

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

Similar Threads

  1. Replies: 4
    Last Post: 05-16-2011, 04:58 PM
  2. Help!! - Corrupted Module
    By rcrobman in forum Modules
    Replies: 3
    Last Post: 04-29-2011, 03:37 PM
  3. Error in Module
    By Alex Motilal in forum Modules
    Replies: 9
    Last Post: 01-21-2011, 09:21 AM
  4. need help with import Module
    By marubal21 in forum Modules
    Replies: 1
    Last Post: 07-22-2010, 12:23 AM
  5. Module not found
    By nooby in forum Modules
    Replies: 1
    Last Post: 12-02-2009, 02:20 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