[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

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.
0
Midnight2005
Asked:
Midnight2005
  • 3
  • 2
1 Solution
 
NickGeorghiouCommented:
Hi,

You can right click on a table and make it Hidden. This will hide the table unless a user goes to Tools->Options and shows Hidden Objects. However you can further restrict them from doing that by disabling toolbars from Startup options as well.

Code for releasing database is as follows:

objAccess1.Application.Quit(Access.AcQuitOption.acQuitSaveAll)
System.Runtime.InteropServices.Marshal.ReleaseComObject(objAccess1)
objAccess1= Nothing

Cheers,
Nick
0
 
Midnight2005Author Commented:
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?
0
 
NickGeorghiouCommented:
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
0
 
Midnight2005Author Commented:
I meant to ask hiding "Database Window", the one that has tables, queries, reprts, macros, etc...
Sounds like it is not possible though.
0
 
NickGeorghiouCommented:
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
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now