Solved

Creating Special Statup Options

Posted on 2008-10-27
11
214 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
Comment Utility
0
 

Author Comment

by:Newbi22
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

Author Comment

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

Expert Comment

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

Author Comment

by:Newbi22
Comment Utility
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
Comment Utility
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
Comment Utility
Many Thanks!!!
0
 
LVL 46

Expert Comment

by:tbsgadi
Comment Utility
Glad to help!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

743 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

16 Experts available now in Live!

Get 1:1 Help Now