Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

zhed0708 (IS/IT--Management)
1 Sep 11 6:19
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  

OlafDoschke (Programmer)
1 Sep 11 6:49
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.
zhed0708 (IS/IT--Management)
1 Sep 11 7:04
sir olaf,....

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

zhed  

MikeLewis (Programmer)
1 Sep 11 7:26
Zhed,

Are you sure that staff.admin contains the value you expect. Might be worth taking a moment to display the value of staff.admin (in a messagebox, for example) immediately before you test it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 

craigber (Programmer)
1 Sep 11 11:49
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 http://www.aksel.com/genmenux/default.htm, which gives you the ability to remove menu options.

Craig Berntson
MCSD, Visual C# MVP, www.craigberntson.com/blog
 

MikeLewis (Programmer)
1 Sep 11 11:56
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
 

craigber (Programmer)
1 Sep 11 12:25
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, www.craigberntson.com/blog
 

MikeLewis (Programmer)
1 Sep 11 12:59
Ah, yes, Craig, that's right. It's been such a long time since I generated an MPR file, I forgot to take it into account.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 

TamarGranor (Programmer)
1 Sep 11 16:02
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
OlafDoschke (Programmer)
2 Sep 11 2:48
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,

Quote (zhed):


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.
zhed0708 (IS/IT--Management)
2 Sep 11 3:23
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  

zhed0708 (IS/IT--Management)
2 Sep 11 3:32
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  

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close