Results 1 to 5 of 5
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862

    Global Error

    I get an immediate Global error. What have I forgotten? I got this from the net for minimizing the Main access window.

    Function fSetAccessWindow(nCmdShow As Long)
    Global Const SW_HIDE = 0
    Global Const SW_SHOWNORMAL = 1
    Global Const SW_SHOWMINIMIZED = 2
    Global Const SW_SHOWMAXIMIZED = 3
    Dim loX As Long
    Dim loForm As Form
    On Error Resume Next
    Set loForm = Screen.ActiveForm
    If Err <> 0 Then 'no Activeform
    If nCmdShow = SW_HIDE Then
    MsgBox "Cannot hide Access unless " _
    & "a form is on screen"
    Else
    loX = apiShowWindow(hWndAccessApp, nCmdShow)
    Err.Clear
    End If
    Else
    If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
    MsgBox "Cannot minimize Access with " _
    & (loForm.Caption + " ") _
    & "form on screen"
    ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
    MsgBox "Cannot hide Access with " _
    & (loForm.Caption + " ") _
    & "form on screen"
    Else
    loX = apiShowWindow(hWndAccessApp, nCmdShow)
    End If
    End If


    fSetAccessWindow = (loX <> 0)
    End Function

  2. #2
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    on what line does the error occur. If you dont get a line, it could be the API lines. But really no way to tell with the information you have provided.

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862
    I figured out part. Global must be removed in the script.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The term 'global' is how most developers describe this kind of object, in whatever language they're working in, but in Access VBA the proper term is 'Public.' In fact, if you have a line like

    Global Const SW_HIDE = 0

    and place the cursor into the Global, then press <F1> Access Help will take you the Public Statement!

    Linq ;0)>

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You should really note where you got the code.
    The original code (AFAICT -> As Far As I Can Tell) was written by Dev Ashish and is posted at http://access.mvps.org/access/api/api0019.htm. (Note the copyright notice)

    Note this code is for A2000 - 2003 and has not been tested with A2007 - 2013 in Win 8 (AFAICT).

    Also see discussion at http://www.utteraccess.com/forum/lof.../t1966467.html (May 3 2011)
    And http://www.access-programmers.co.uk/...d.php?t=238389

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

Similar Threads

  1. Can't See Global Variable
    By CementCarver in forum Programming
    Replies: 12
    Last Post: 09-19-2013, 12:28 PM
  2. Global Variables?
    By futurezach in forum Reports
    Replies: 4
    Last Post: 06-20-2013, 03:45 PM
  3. Global variable
    By ramdandi in forum Queries
    Replies: 3
    Last Post: 12-18-2011, 01:01 AM
  4. Global Error Handler Issue
    By usmcgrunt in forum Programming
    Replies: 1
    Last Post: 11-02-2011, 08:26 PM
  5. Help Please - Global Vars
    By graviz in forum Programming
    Replies: 3
    Last Post: 02-18-2010, 10:36 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