Menu Questions

S

Sharkbyte

1) I want to utilize a Log Out option. Is there a VBA command to close all
open forms rather than try and check for every one before opening the login
screen, or is there a way to essentially "restart" the app?

2) Can the menu options be changed, based on who logs in (security levels
within the application)? In most cases, I would simply want to grey out
those functions the person isn't allowed to use.

TIA

Sharkbyte
 
A

Albert D. Kallal

Sharkbyte said:
1) I want to utilize a Log Out option. Is there a VBA command to close
all
open forms rather than try and check for every one before opening the
login
screen, or is there a way to essentially "restart" the app?

Are you talking about "user level security" here? I don't think so, but you
could exit and shell out to the same applicaton in code...that would
re-start the application...
2) Can the menu options be changed, based on who logs in (security levels
within the application)? In most cases, I would simply want to grey out
those functions the person isn't allowed to use.

Sure, if you are using user level security, then you can in code go:

if IsInGroup(CurrentUser,"SuperUser" then

CommandBars("menu bar").
Controls("records").Controls("refresh").Visible = True

end if

or, for a cascading menu, you go:

if IsInGroup(CurrentUser(),"InvoideDeleteGroup") = true then

CommandBars("myCustomBar").
Controls("AdminOptions").
Controls("DleeteInvoice").Visible = True

end if

Note that short cut menus are their own name also:

commandbars("your shortcut name").Contorls("contorlName").visiable = false

The function IsInGroup is reproducted below:

Public Function IsInGroup(UsrName As String, GrpName As String) As Boolean
'Determines whether UsrName is a member of GrpName

Dim grp As Group
Dim IIG As Boolean
Dim usr As user

IIG = False

For Each usr In DBEngine.Workspaces(0).Users
If usr.Name = UsrName Then GoTo FoundUser
Next

GoTo IIG_Exit

FoundUser:
For Each grp In usr.Groups
If grp.Name = GrpName Then IIG = True
Next

IIG_Exit:
IsInGroup = IIG


End Function
 
S

Sharkbyte

Albert:

Thanks for the help. FYI, your code works even without using User-Level
security. I can define internal security levels, and using either IF or CASE
statements can modify the visible/enabled properties of each menu item.

Thanks again.

Sharkbyte
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top