Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

menu problem

Status
Not open for further replies.

zhed0708

IS-IT--Management
Jun 25, 2011
41
PH
plz help....

i want to disable my menus and i have this code in my OK command in login:

IF staff.admin = .f. then
SET SKIP OF PAD maintenance OF _msysmenu .f.
SET SKIP OF PAD admin OF _msysmenu .f.
ENDIF

i have fields in my staff table of admin and have its type of logical..i want to disable my menus maintenance and admin when a non admin user is login..then it enables when admin user is login...when i run my program and login as a non admin user, the menus maintenance and admin won't disable. it remains enables..what is the problem here? it is in my code or in my table where my admin field is logical?

thanx for advance....

zhed
 
You should also set skip to .t., if staff.admin = .t.

That menas:
Code:
IF staff.admin then
    SET SKIP OF PAD maintenance OF _msysmenu .f.
    SET SKIP OF PAD admin OF _msysmenu .f.
ELSE
    SET SKIP OF PAD maintenance OF _msysmenu .t.
    SET SKIP OF PAD admin OF _msysmenu .t.
ENDIF

Bye, Olaf.
 
sir olaf,....

i tried your code but still won't disable my menu maintenance and admin...what should i do?

zhed
 
I'll throw in a different option. Disabled items indicate there is someway for the user to enable them. In the case of a non-admin, there is no way to do it so the menu items should actually be removed. Download Genmenux at which gives you the ability to remove menu options.

Craig Berntson
MCSD, Visual C# MVP,
 
Craig has made a good point. However, if you don't want to show a menu, it might be easier simply not to show it in the first place. In other words, at the place where you define the menu, do something like this:

Code:
IF staff.admin
  DEFINE BAR .... 
  etc.
ENDIF

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Good idea, Mike, but that may mean hacking the .mpr file, which is not a good idea because it gets regenerated. The nice thing about GenMenuX is you don't have to hack. It just works.

Craig Berntson
MCSD, Visual C# MVP,
 
Rather than doing this in code, why don't you use the SKIP FOR option in the Menu Designer? Just put NOT Staff.Admin as the expression for each relevant menu item.

Tamar
 
Putting an expression there instead of .t./.f. makes the menu reevaluate it from time to time, so if the Staff table only is open during creation/modification of the menu, that will fail as soon as the table is closed and the menu is use afterwards. I think therefor e zhed decided to edit the existing menu via SET SKIP after each login instead of recreating it.

@zhed, if that's still not working, you should debug what's going on directly after a login, there must be some flaw in your coding, SET SKIP OF does set the skip of menus or menu items, there's no bug in there. Put a breakpoint into the click of the login button or at least this code modfiying the menu and check what is running.

Also, last not least: My assumption on Stuff.admin is, it's .t. for admins, if you set that flag according to SKIP logic you'd have the inverted value, but that wouldn't make sense in the table.

admin = .F. means deactivating admin menu, so SKIP must be .T. and vice versa. You initially had that logic wrong,

zhed said:
IF staff.admin = .f. then
SET SKIP OF PAD maintenance OF _msysmenu .f. && wrong, must be .t.
SET SKIP OF PAD admin OF _msysmenu .f. && wrong, must be .t.
ENDIF

Also, your code only changes the menu if a non admin logs in. If an admin then logs in, the menu isn't modified. My code in the first answer solves these two problems. If it does not, I'm temped to say it doesn't run.

Bye, Olaf.
 
sir olaf.....

this is my code in log in form which exactly the code in disabling my menu happens.

with thisform
select staff
IF thisform.text1.value=staff.password then
thisform.Refresh()
SET SKIP OF MENU _msysmenu .f.
thisform.Visible = .f.
thisform.release
thisform.Refresh ()

else
messagebox ('Invalid Entry!')
.text1.value=""
.text1.setfocus
ENDIF

IF staff.admin = .f. then
SET SKIP OF PAD maintenance OF _msysmenu .t.
SET SKIP OF PAD admin OF _msysmenu .t.
ELSE
SET SKIP OF PAD maintenance OF _msysmenu .f.
SET SKIP OF PAD admin OF _msysmenu .f.
ENDIF
endwith


plz check my code if it is correct...thanx...

zhed
 
sorry sir.....

i got the problem.the code is correct and my mistake is not placing the name of my pad in the menu designer option..thanx for your help...

zhed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top