Define how Access opens using VBA (1 Viewer)

sstasiak

Registered User.
Local time
Today, 01:46
Joined
Feb 8, 2007
Messages
97
I should have updated this thread a few days ago....I figured out how to disable pretty much everything but what the user can do in the forms.

Once the DB is converted to .accde(i'm using 2007), you have to change the extension to .accdr. This opens the DB using the runtime switch. Pretty easy solution.
 

vbaDev

Registered User.
Local time
Today, 01:46
Joined
Feb 26, 2007
Messages
64
This works great, actually, much better for my purposes than the API method.

Access is hidden and the form can still be minimized/restored from the taskbar and switched to from other apps via the Taskbar.

I also have a Show/Hide access toggle button on my form, for which I have a Select Case structure (based on button's state).

One is exactly the same as the form's On-Open event:

docmd.runcommand acCmdAppMinimize

and the other, to restore Access:

docmd.runcommand acCmdAppRestore

but these commands don't work from my toggle button. Why is that?
I also tried the Maximize method instead of Restore and with it, but it didn't work.

2nd question, of course, is how to allow viewing of reports and I also have to display a table at one point (i know i can make a form based on the table, but can i show the table?)

Problem is, in Access 2000 reports don't have a PopUp property yet :(

Thanks!

I use this non-API method of hiding the database window for all my access applications. IMO it looks better and more like a program only taking up a little of your screen. The method I use it when my default form opens (Main Menu) I have the On Open Event Procedure set as:

Code:
Private Sub Form_Open(Cancel As Integer)
DoCmd.RunCommand acCmdAppMinimize
End Sub

So when the db opens it automatically hides the DB window/ access window.

@sstasiak

If you want to turn off toolbars and such programatically simply create 2 modules and put this code in it.

Module - turnon:
Code:
Option Compare Database
Option Explicit

Function toolbarson()
DoCmd.ShowToolbar "Menu Bar", A_TOOLBAR_YES

'DoCmd.ShowToolbar "Database", A_TOOLBAR_YES
'DoCmd.ShowToolbar "Relationships", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Table Design", A_TOOLBAR_NO
'DoCmd.ShowToolbar "table Datasheet", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Query Design", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Query Datasheet", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Form Design", A_TOOLBAR_YES
'DoCmd.ShowToolbar "Form View", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Filter/Sort", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Report Design", A_TOOLBAR_YES
'DoCmd.ShowToolbar "Print Preview", A_TOOLBAR_YES
DoCmd.ShowToolbar "Toolbox", A_TOOLBAR_YES
'DoCmd.ShowToolbar "Palette", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Macro", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Microsoft", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Web", A_TOOLBAR_NO
DoCmd.ShowToolbar "Formatting (Page)", A_TOOLBAR_YES
'DoCmd.ShowToolbar "Print Menu", A_TOOLBAR_YES

End Function

Module turnoff:
Code:
Option Compare Database

Function toolbarsoff()

DoCmd.ShowToolbar "Menu Bar", A_TOOLBAR_NO
DoCmd.ShowToolbar "Database", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Relationships", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Table Design", A_TOOLBAR_NO
'DoCmd.ShowToolbar "table Datasheet", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Query Design", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Query Datasheet", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Form Design", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Form View", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Filter/Sort", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Report Design", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Print Preview", A_TOOLBAR_NO
DoCmd.ShowToolbar "Toolbox", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Palette", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Macro", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Microsoft", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Web", A_TOOLBAR_NO
DoCmd.ShowToolbar "Formatting (Page)", A_TOOLBAR_NO
'DoCmd.ShowToolbar "Print Menu", A_TOOLBAR_NO

End Function

Just adjust the commented toolbars to show or not show which ever toolbars; if you create your own custom toolbars you can also set that code in here as well.

Once you have the modules set up then just create a macro called "Autoexec" (this will run automatically everytime you open the database so you won't have to worry about adding this code to a button or form)

In the Autoexec macro refer to the "turnoff" function.

RunCode
toolbarsoff ()

**When hiding the database window -
On the note of only being able to have 1 pop-up form open at a time this is not true; you also don't have to set the Modal property to "YES" if you leave Modal as "NO" and PopUp as "YES" for the form(s) then it will allow you to open more than 1 form at a time and still be able to switch focus between the different forms. What's better is that if you minimize the forms they will minimize just above the "Start" button instead of all going to the taskbar seperately.

There is a way to view reports without having to Unhide the access db window. You can set the reports PopUp property to "YES" and this will open just like the forms. I have leaned away from this because I did find the only downside is trying to get the popup report sized correctly to be able to view easily, but it is possible to do.
 

PC User

Registered User.
Local time
Yesterday, 22:46
Joined
Jul 28, 2002
Messages
193
I noticed that also. Access 2K doesn't have the PopUp property for reports. What version of Access are you using, gold007eye? Is there an alternate way to make a report into a PopUp or equivelant for Access 2K? I do like your non-API method of hiding the database window.

Thanks,
PC

PS. Can a new property like PopUp be added to AllReports using AccessObjectProperties?
I tried this, but can't get it to work.
Code:
Sub AddCustomReportProperty(strReportName As String, _
                                  strPropName As String, _
                                  varPropValue As Variant)
    ' Add custom properties to the AccessObjectProperties
    '  collection that is associated with an AccessObject object.
    
    With CurrentProject.AllReports(strReportName).Properties
        .Add strPropName, varPropValue
    End With
End Sub
 
Last edited:

vbaDev

Registered User.
Local time
Today, 01:46
Joined
Feb 26, 2007
Messages
64
Hi. I tried your method and it works, of course, BUT :)

1. while the report is open, users have access to the Access window. I know, I can disable many features, but isn't there a way around that, maybe somehow showing the report maximized or really even adding a PopUp property as someone suggested?

2. if report is maximized, user can always accidentally click the "Close" box of Access (and quit application) instead of Report's "close" button. That's not a good form either.

I wonder if we can all perfect this method. I know, the easier way is to upgrade Access :D but it's up to my employer, not me (and it's not as simple for large organizations).

Thanks!

There really isn't any code to give you. It's just a matter of running the normal form opening and closing code, the report opening code, and code within the on close event of the reports. The key things to remember are:

1. When Access opens you need to minimize the app window using DoCmd.RunCommand acCmdAppMinimize and THEN open the form. So, an autoexec macro is probably the way you have to go instead of setting a startup form.

2. Make sure all forms are set to POPUP.

3. Then, whenever you need to move from form to form, you will close the first form first and then open the second (the code to close the first and open the second can be on the first form)

4. When opening a report, use
DoCmd.Close acForm, Me.Name, acSaveNo
Docmd.RunCommand acCmdAppMaximize
Docmd.Open Report "YourReportName"

5. Then in each Report's on close event, put
DoCmd.RunCommand acCmdAppMinimize
DoCmd.Open Form "YourFormNameHere"
 

boblarson

Smeghead
Local time
Yesterday, 22:46
Joined
Jan 12, 2001
Messages
32,059
All of your questions are reasons why I chose not to use it. It is a big pain in the butt to try to implement and make all of the little idiosyncracies work. So, I don't have answers for you on that one as I abandoned trying to do this years ago for many of the same reasons listed in your questions.
 

vbaDev

Registered User.
Local time
Today, 01:46
Joined
Feb 26, 2007
Messages
64
Thanks, Bob. It sure looks slick, though. I guess our answer is: we should use VB.NET or some real environment and not Access :)

Or maybe Microsfot could redesign Access to allow final apps to become stand-alone (or "almost" stand-alone).

no end to wishing...

:D

All of your questions are reasons why I chose not to use it. It is a big pain in the butt to try to implement and make all of the little idiosyncracies work. So, I don't have answers for you on that one as I abandoned trying to do this years ago for many of the same reasons listed in your questions.
 

Users who are viewing this thread

Top Bottom