Link to home
Start Free TrialLog in
Avatar of Midnight2005
Midnight2005

asked on

Openning Access from .NET

I have Access 2003 and VS 2005.
This is what I currently have:

            objAccess1 = New Access.ApplicationClass()
            If Not objAccess1.Visible Then objAccess1.Visible = True
            objAccess1.OpenCurrentDatabase(filepath:=strRptPath & "x.MDB", Exclusive:=False)

            If Not objAccess1.UserControl Then objAccess1.UserControl = True
            objAccess1.RunCommand(Command:=Access.AcCommand.acCmdAppMaximize)

            objAccess1.DoCmd.SelectObject(ObjectType:=Access.AcObjectType.acMacro, _
            ObjectName:="MyForm", InDatabaseWindow:=True)
            objAccess1.DoCmd.RunMacro("MyForm")
            objAccess1.DoCmd.Maximize()

I need to open a form in Access from my VB app, I maximized it but users are still able to go to Database Windows inside Access and be able to reach my LInk Table to SQL Server. I don't want them to see the records like that. I need to put some security.
I saved the Access going to Startup, unchecked "Display Database WIndow", but no help, it's still showig.
Any help?

And the other thing is once Access opens thru my app, even if the user closes it, nobody can open any other Access databases until my Application is completely closed. I realized the Access stays in memory somehow even if they click the X on the corner. I tried disposing it but it still stays until we exit the app completely.
ASKER CERTIFIED SOLUTION
Avatar of NickGeorghiou
NickGeorghiou
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Midnight2005
Midnight2005

ASKER

Reaising the com object was the key, thanks very much Nick, worked like a charm.

Making tables invicible doesn't stop users to be able to go in, some keep show hidden setting on. I diabled the toolbar from Startup options. When I directly open, it's fine but when the application opens the Access database, and when user closes the form, they are able to see the Database Window.
I wonder if there's a way somehow...maybe using the objAccesss?
Hi again,

I am not sure if you can do something like,

objAccess1.Application.SetOption("Show Hidden Objects", False)

or you may need to substitute 0 for False.

Cheers,
Nick
I meant to ask hiding "Database Window", the one that has tables, queries, reprts, macros, etc...
Sounds like it is not possible though.
Hi again,
VBA has a StartupShowDBWindow option so I assume you might be able to use this from .NET as well. Haven't tested it but I would assume it is something like:

objAccess1.Application.StartupShowDBWindow = False

Hope this helps,
Nick