Results 1 to 14 of 14
  1. #1
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

    Microsoft access cannot find the object 'fSetAccessWindow(SW_SHOWNORMAL).'


    http://www.access-programmers.co.uk/...d.php?t=217400 <Following this thread

    I created a Module and put in the big code. The module in my database is named "test". I then put:

    "fSetAccessWindow(SW_SHOWMINIMIZED)"

    on the on open event of my form and I receive the error in my title.

    Can anyone suggest how to fix this issue?

    Thanks

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Perhaps you can try renaming your module to something like modTest.

    What happens if you type
    ?SW_SHOWMINIMIZED

    into the immediate window and then hit the enter key? Does it respond with the value 2?

  3. #3
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Code:
    Perhaps you can try renaming your module to something like modTest.
    This still produces the same error.

    Quote Originally Posted by ItsMe View Post
    What happens if you type
    ?SW_SHOWMINIMIZED

    into the immediate window and then hit the enter key? Does it respond with the value 2?
    I don't understand what the immediate window is. Thanks for the reply, hopefully you can help troubleshoot this.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I will be in and out of meetings today. Perhaps you can post your code here. Post the name of your module and all of the code within the module. Also, post the entire sub-procedure that calls the function.

    You can use the immediate window to see if the Global Constant is working properly and independently from the function. A keyboard shortcut to display the Immediate Window is Ctrl+G. In my VBA editor, the Immediate Window is docked at the bottom of the Editor/IDE.

  5. #5
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Oh okay I know what you mean now. Also in the first post it links to all of the code. That's where I got it from.

    yes it does return the value 2 in the immediate window.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I viewed the link you provided prior to my previous post

  7. #7
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Okay I can post what you asked for no problem:

    Module name: TestMod

    I then pasted this in the module:

    Code:
    Option Compare Database 
    Option Explicit 
     
    Global Const SW_HIDE = 0 
    Global Const SW_SHOWNORMAL = 1 
    Global Const SW_SHOWMINIMIZED = 2 
    Global Const SW_SHOWMAXIMIZED = 3 
     
    Private Declare Function apiShowWindow Lib "user32" _ 
    Alias "ShowWindow" (ByVal hWnd As Long, _ 
    ByVal nCmdShow As Long) As Long 
     
    Function fSetAccessWindow(nCmdShow As Long) 
         
        Dim loX As Long 
        Dim loForm As Form 
        On Error Resume Next 
        Set loForm = Screen.ActiveForm 
         
        If Err <> 0 Then 
            loX = apiShowWindow(hWndAccessApp, nCmdShow) 
            Err.Clear 
        End If 
         
        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 
        fSetAccessWindow = (loX <> 0) 
    End Function
    This was then pasted into the form open event: (I also tried it in on load)

    fSetAccessWindow(SW_SHOWNORMAL)

    thanks for the replies so far.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Try
    Call fSetAccessWindow(SW_SHOWNORMAL)
    or
    fSetAccessWindow SW_SHOWNORMAL

  9. #9
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Sadly this didn't work either. The office is closing here shortly. I will provide more details of the error on Monday. Thanks again

    have a good weekend

  10. #10
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Well. Trying both suggestions today provides the original error. Last Friday it was a different error, but today its Microsoft Access cannot find the object 'fSetAccessWindow(SW_SHOWMINIMIZED). I'm not set on using this code, I just need to secure the database on a machine that does have Microsoft access. I don't want them messing with the anything. I'll have another google and look for a sample possibly.

    Thanks so far.

  11. #11
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    How is it possible top get the error
    Microsoft Access cannot find the object 'fSetAccessWindow(SW_SHOWMINIMIZED).

    when using
    fSetAccessWindow SW_SHOWNORMAL

  12. #12
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Ahh sorry I should have said; I was testing a few things to try and replicate the earlier error. It's the same with using SHOWNORMAL though. I tried form load and form open again also.

  13. #13
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    FWIW, using the load event of a form I was able to get both of the call statements in post #8 to work. I copied the function into a blank DB file. I did not get any errors. However, while using tabbed windows, nothing spectacular happened. It looked like something tried to happen, but the only thing that did happen was the application window resized from maximized.

  14. #14
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    I will try this in a blank database; thanks for testing that. I'm in meetings all the rest of this week so I may be slow getting back to it. But thanks again for your time ItsMe

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

Similar Threads

  1. Replies: 7
    Last Post: 11-13-2014, 07:46 AM
  2. Replies: 4
    Last Post: 06-25-2014, 01:44 PM
  3. Replies: 2
    Last Post: 09-07-2012, 03:57 PM
  4. Replies: 1
    Last Post: 09-03-2011, 07:01 PM
  5. Replies: 6
    Last Post: 10-30-2010, 08:42 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