Disable Editing Subform in navigation form

there is a code for it. better to put the code in the Load event of the nav form,
becoz right's of each user will likely not change, so using current event you always enable/disable the control.
Code:
Dim bolJumped as Boolean
If txtaccesstab1= False Then ' from dlookup 
    Forms!frmMain!Nav1.Enabled = False
Else
    Forms!frmMain!Nav1.Enabled = True
    If bolJumped = False Then
       bolJumpted = True
       Forms!frmMain!Nav1.Setfocus
       Sendkeys "{ENTER}"
    End If
End If

If txtaccesstab2= False Then ' from dlookup 
    Forms!frmMain!Nav2.Enabled = False
Else
    Forms!frmMain!Nav2.Enabled = True
    If bolJumped = False Then
       bolJumpted = True
       Forms!frmMain!Nav2.Setfocus
       Sendkeys "{ENTER}
    End If
End If

If txtaccesstab3= False Then ' from dlookup 
    Forms!frmMain!Nav3.Enabled = False
Else
    Forms!frmMain!Nav3.Enabled = True
    If bolJumped = False Then
       bolJumpted = True
       Forms!frmMain!Nav3.Setfocus
       Sendkeys "{ENTER}"
    End If
End If

Well, that's worked like charm :D:D

Thanks alot @arnelgp and thanks to @theDBguy
 
Well, that's worked like charm :D:D

Thanks alot @arnelgp and thanks to @theDBguy

Hi. Glad to hear you got it sorted out. Good luck with your project.
 
Hi,

I am now having the same problem, on my Navigation Form when a user clicked a button it automatically shows the "subform" associated with "Navigation Target Name", now I wanted to disable this "subform" based on User Roles, others tab are ok to play with are there any solutions to this one? Thanks in advance!
 
initially set the tab's navigationTargetName = ""
and set it (on click event) based on who is the user.
Hi Arnelgp,

I tried your approach but doesn't seem to get the job done, it will work initially when the logged user is not allowed to view the "subform" under the navigation tab, but when an allowed user is the active one, I need to click that navigation tab to show the "subform", what I need is when a trusted user is logged the default behavior of the Navigation should be as is and changes only whenever an unauthorized user is currently logged-in.

Hope it make sense :)
 
I think you're all making this harder than it needs to be. It doesn't matter whether or not the subform is locked. All that matters is that you stop an update by an unauthorized user. Therefore, in the subform's on Dirty event, check the credentials of the user. If he is not authorized, undo the the update to the record and give the user an error message.
Hi Pat,

I got your point on this, but what I am trying to accomplish is what my professor in PROG/SAD class always taught us "never give/show an option to an unauthorized user in your program/application..." for there will be more questions/explanations involved plus it is not a good practice to let them spend their time filling-up something that they are not allowed to save in the end.

I am looking on a solution to prevent the above so during the "On Load" or an "On Click" event of the main Navigation is what I am targetting, but still no luck :(
 
here is a simple demo.

enter user "a" and password 1.
if you go to the "tab 1", there won't be any subform.

close and re-open the navigation form.

enter user "b" and password 2.
goto tab 1. chan-charan!

** see the code-behind the tab button.
 

Attachments

Thanks Arnel, it works logically on a single nav, but below is the screenshot of my form (Horiz & Vert Left Nav) the problem I am facing is I want the "Add New Product" and "Edit Product" either be disabled or hidden including the "subforms" so the user can only navigate/click the "View Products" otherwise if they are a trusted user all nav buttons & "subforms" are enabled.

I cant seem to trap the nav button event, by default when a user clicked the "Products" menu it opens up the "Add New Product" and display the underlying subform, what I am trying to do is to trap the event based on user level when clicking a nav. buttons on the left side (parent).

1637753468019.png
 
i tried to mimic your 2 navigation form.
same demo try user "a" (pwd=1) first.

close and re-open the "navigation form 1"
user "b" (pwd=2).

another... "chan-charan!"
 

Attachments

Hey Pat,

Nice to see a fellow COBOL programmer on this thread, I started as COBOL/CICS Programmer way back on Mid/Mainframes lolz.

Anyways, @arnelgp got the drift of what I am tackling and it works as I envisioned!

Thanks for your insights and as always "we" as programmers can always find a way to circumvent and/or find a work around on something...

Cheers!
 

Users who are viewing this thread

Back
Top Bottom