Solved

Creating Special Statup Options

Posted on 2008-10-27
11
226 Views
Last Modified: 2013-11-29
Hello,

I have a Macro called "AutoExec". with a Runcode in it called "AutoExec()"

I have a module called 1234 with the following code below.

I am user mf431. As you can see, when I sign in, I can see the database window, but when others sign in, they get form called "View Reports"

 However, I need to bring back more options  when I am signed in becuase I am going to be disabling the "Shift" key. I have also "UNCHECKED" all of the options in Tools/Startup.......

Basically, I am trying to create a special startup for myself vs the other users. For example, I need the following
1. Full Menus (File, edit, view, etc......)
2. Need the full "database" toolbar.
3. I created a custom toolbar called "Preview" that will load when others sign in.

NewBi22
Function AutoExec()
 

If CurrentUser() = "mf431" Then

DoCmd.SelectObject acTable, "", True

Else

DoCmd.SelectObject acTable, "", True

RunCommand acCmdWindowHide

DoCmd.OpenForm "View Reports", acNormal

End If

End Function

Open in new window

0
Comment
Question by:Newbi22
  • 6
  • 5
11 Comments
 
LVL 46

Expert Comment

by:tbsgadi
ID: 22819558
0
 

Author Comment

by:Newbi22
ID: 22826230
Gary,
I followed the steps provided. However, I am getting errors. I get a VB error on this:
ChangeProperty
Does it matter that I am using 2003.
I have been able to get the button to show only for me and get the hour glass, but I get the error.
 
Newbi22

Sub SetLimitedStartupProperties()

ChangeProperty "StartupForm", dbText, "Startup", True

ChangeProperty "StartupShowDBWindow", dbBoolean, False, True

ChangeProperty "StartupShowStatusBar", dbBoolean, True, True

ChangeProperty "AllowBuiltinToolbars", dbBoolean, False, True

ChangeProperty "AllowToolbarChanges", dbBoolean, False, True

ChangeProperty "AllowFullMenus", dbBoolean, False, True

ChangeProperty "AllowShortcutMenus", dbBoolean, False, True

ChangeProperty "AllowBreakIntoCode", dbBoolean, False, True

ChangeProperty "AllowSpecialKeys", dbBoolean, False, True

ChangeProperty "AllowBypassKey", dbBoolean, False, True

End Sub

Open in new window

0
 

Author Comment

by:Newbi22
ID: 22826447
Gary,
More information. I took out the following line.
ChangeProperty "StartupForm", dbText, "Startup", True
Also changed all the Full Properties to True and all the Limited Propertise to False. This works nice, but here is the thing. I do not want all the properties available to all. I just want then limited to me.
Can I run an AutoExec macro to run upon load. The if CurrentUser = "mf431" Then
Give me all options
Else
Do not give me all options
End if
Newbi22
 
0
 

Author Comment

by:Newbi22
ID: 22826816
Gary,
Newest addition. I need help here. I created a AutoExec macro with the Run code as Startup().
Below is my module to run upon startup. But it only works every other time. If I sign in, I get the correct options. Then I exit and sign in as another user, still my options. I exit and sign in again as that same user, I than get the correct option. But if I sign in again, I get the wrong options.
It is keeping the previous option for 1 more sign-in.
How do I stop that. Evaluate the code also. I have about 100 users of the database.
Newbi22

Function Startup()
 

If CurrentUser() = "mf431" Then
 

ChangeProperty "StartupShowDBWindow", dbBoolean, True

ChangeProperty "StartupShowStatusBar", dbBoolean, True

ChangeProperty "AllowBuiltinToolbars", dbBoolean, True

ChangeProperty "AllowToolbarChanges", dbBoolean, True

ChangeProperty "AllowFullMenus", dbBoolean, True

ChangeProperty "AllowShortcutMenus", dbBoolean, True

ChangeProperty "AllowBreakIntoCode", dbBoolean, True

ChangeProperty "AllowSpecialKeys", dbBoolean, True

ChangeProperty "AllowBypassKey", dbBoolean, True
 

Else
 

ChangeProperty "StartupShowDBWindow", dbBoolean, False

ChangeProperty "StartupShowStatusBar", dbBoolean, True

ChangeProperty "AllowBuiltinToolbars", dbBoolean, False

ChangeProperty "AllowToolbarChanges", dbBoolean, False

ChangeProperty "AllowFullMenus", dbBoolean, False

ChangeProperty "AllowShortcutMenus", dbBoolean, False

ChangeProperty "AllowBreakIntoCode", dbBoolean, False

ChangeProperty "AllowSpecialKeys", dbBoolean, False

ChangeProperty "AllowBypassKey", dbBoolean, False
 

End If
 

End Function
 

Function ChangeProperty(stPropName As String, _

PropType As DAO.DataTypeEnum, vPropVal As Variant) _

As Boolean

' Uses the DDL argument to create a property

' that only Admins can change.

'

' Current CreateProperty listing in Access help

' is flawed in that anyone who can open the db

' can reset properties, such as AllowBypassKey

'

On Error GoTo ChangeProperty_Err
 

Dim db As DAO.Database

Dim prp As DAO.Property
 

Const conPropNotFoundError = 3270
 

Set db = CurrentDb

' Assuming the current property was created without

' using the DDL argument. Delete it so we can

' recreate it properly

db.Properties.Delete stPropName

Set prp = db.CreateProperty(stPropName, _

PropType, vPropVal, True)

db.Properties.Append prp
 

' If we made it this far, it worked!

ChangeProperty = True
 

ChangeProperty_Exit:

Set prp = Nothing

Set db = Nothing

Exit Function
 

ChangeProperty_Err:

If Err.Number = conPropNotFoundError Then

' We can ignore when the prop does not exist

Resume Next

End If

Resume ChangeProperty_Exit

End Function

Open in new window

0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 22828962
You're right.
You can only change the properties for the next time you open the database.
You should have a button to "lock" the database, and when you go in ,you"ll need to open the DB twice.
I have it that my database is always open & when  I release it to other users I close it.
I also add the attached code to my Startup just in case I release an open version by mistake.

 Set dbs2 = CurrentDb

     If dbs2.Properties("StartupShowDBWindow") Then

        If CurrentUser <> "mf431"  Then

           MBox "Call Admin for Support"

        DoCmd.Quit

        Exit Function

        End If

    End If

Open in new window

0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:Newbi22
ID: 22835328
Gary,
What type of Lockout code do you use.
Considering I disable the Shift key.
 
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 22838621
The same code as you use.
If you open the DB twice then AllowBypassKey will be true
0
 

Author Comment

by:Newbi22
ID: 22845500
Gary,
I think I have it set up correct and understand how it works. But, this still does not stop someone from entering the system using the shift key. Am I correct or do I have to do that seperate.
Newbi22
0
 
LVL 46

Accepted Solution

by:
tbsgadi earned 500 total points
ID: 22846102
you need to run the lock sequence to close the DB ie all the Changepoperty false & then nobody can use the bypass key
0
 

Author Closing Comment

by:Newbi22
ID: 31510540
Many Thanks!!!
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 22850146
Glad to help!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

914 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now