Error 2455: You entered an expression that has an invalid reference to the property visible

Posted on 2003-03-27
Medium Priority
Last Modified: 2007-12-19
I get the following error message when using automation to control MSAccess.

"Error 2455: You entered an expression that has an invalid reference to the property visible"

MSAccess has user-level security.  To bypass this using automation, I have shelled out, passing the necessary parameters available when opening MSAccess from command line.  Then I have captured the instance using GetObject(, "Access.Application").

Here's the relevant section of VB code...

    On Error Resume Next
        Set GetoAcc = GetObject(, "Access.Application")
        If Err <> 0 Then ' No instance of MS Access is open.
            If IsMissing(varUser) Then varUser = "Admin"
            cmdLine = AccPath
            cmdLine = cmdLine & " /nostartup /user " & varUser
            If Not IsMissing(varPwd) Then cmdLine = cmdLine & " /pwd " & varPwd
            Shell PathName:=cmdLine, WindowStyle:=0
            On Error GoTo WaitForAccess
                Set GetoAcc = GetObject(, "Access.Application")
            On Error Resume Next
        End If
        GetoAcc.visible = True

It is on the last line that I get this error message.  HELP!

Question by:IqbalHamid
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 58

Accepted Solution

Jim Dettman (Microsoft MVP/ EE MVE) earned 200 total points
ID: 8217812
What is it that your trying to achieve?  You can specify the window argument on the shell command.

Take a look at:

HOWTO: Automate a Secured Access Database Using Visual Basic

Also, I don't see where your specifying the /wrkgrp switch.  It's not causing the error, but may be a problem down the road.


Author Comment

ID: 8225910
Thank you Jim.  That site was exactly what I required.

Just FYI, I had an MS Access database with BOTH user-level security AND database password set.

It is not possible to directly access OLE automation of MSAccess in such a scenario because it is not possible to pass ALL the necessary security info (UserName, UserPassword and Database Password) via parameters.

I have got around user-level security by shelling out and taking advantage of sitches available during command line launch, THEN capturing that instance using GetObject(, "Access.Application").

I got round the 2nd problem of the database password by opening up the MSAccess instances DBEngine object using DAO, passing in the database password as a parameter there.

    GetoAcc.DBEngine.DefaultUser = varUser      
    GetoAcc.DBEngine.DefaultPassword = varPwd
    GetoAcc.DBEngine.SystemDB = sWIF
    Set wks = GetoAcc.DBEngine.CreateWorkspace("wks", varUser, varPwd, dbUseJet)
    Set db = wks.OpenDatabase(sDBPath, False, False, "MS Access;UID=" & varUser & ";PWD=AnUbhalAsAirde")
    ' Open the database within oAcc...
    GetoAcc.OpenCurrentDatabase sDBPath, False

I wanted the MSAccess instance invisible most of the time except later when previewing reports I needed to make it temporarily visible but was getting the above error message.

Thanks again for your help!

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question