Disable Editing Subform in navigation form (1 Viewer)

alvingenius

IT Specialist
Local time
Today, 13:26
Joined
Jul 10, 2016
Messages
169
Hello

i've main form named "frmMaster" and it have Navigation form with tabs and a tab button named "Profile" to open subform named "subProfile" inside navigation form

this subform is opened directly when i open "frmMaster" because it's in the first tab

and i'm trying to do a permissions stuff to edit "Profiles" in this subform "SubProfile" based on current logged user

my issue is ! that i want to disable editing on this subform for someusers

and i've already disabled the tab button named " Navprofile" !! but it's already opening the subform
for that i want to disable edits on this subform too

i've used :
Code:
Forms!frmMain!Navprofile.Enabled = False
to disable the tab button from access
i want a code to disable the subform linked in this button

P.s
the navigation form have 5 tabs , means i dont wanna disable the whole navigation form

Thanks
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:26
Joined
Oct 29, 2018
Messages
21,454
Hi. You could try something like:
Code:
Forms!frmMain![Navigation Subform].Enabled = False
Hope it helps...
 

alvingenius

IT Specialist
Local time
Today, 13:26
Joined
Jul 10, 2016
Messages
169
Hi. You could try something like:
Code:
Forms!frmMain![Navigation Subform].Enabled = False
Hope it helps...

i know that already but it will apply only if i wanna disable edits on the whole navigation form

in my case i dont :(

only the subform in one of tabs i need to disable

can we add subform name in your code to gt it ?

and i've updated the thread
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:26
Joined
Oct 29, 2018
Messages
21,454
i know that already but it will apply only if i wanna disable edits on the whole navigation form

in my case i dont :(

only the subform in one of tabs i need to disable

can we add subform name in your code to gt it ?

and i've updated the thread
Hi. That is the name of the subform, or at least it represents it. And to only disable it for certain tabs, then you'll need to execute it every time the user changes to a different tab - either disable or enable depending on the tab. In a Nav Form, there is only one subform control, so you'll have to manipulate the same control for each tab.
 

alvingenius

IT Specialist
Local time
Today, 13:26
Joined
Jul 10, 2016
Messages
169
Hi. That is the name of the subform, or at least it represents it. And to only disable it for certain tabs, then you'll need to execute it every time the user changes to a different tab - either disable or enable depending on the tab. In a Nav Form, there is only one subform control, so you'll have to manipulate the same control for each tab.

user wont execute it again because if he changed the tab he can't open the disabled tab again

my issue is because of nav form opening the first tab subform directly

is there a way to make users to click on tab to show subforms inside ?

i think that will help my case :rolleyes:
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:26
Joined
Oct 29, 2018
Messages
21,454
user wont execute it again because if he changed the tab he can't open the disabled tab again

my issue is because of nav form opening the first tab subform directly

is there a way to make users to click on tab to show subforms inside ?

i think that will help my case :rolleyes:
Hi. I'm not sure I understand your question. If you disable the subform, it shouldn't also disable the tabs. So, the user should be free to click on the next tab when they want to. At that time, you can disable the subform, so they can work on it.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:26
Joined
May 7, 2009
Messages
19,233
just put your navigation form in design view.
click on the NavigationSubform.
on its property->data->locked = Yes.

when it's time to unlock:

Forms![NavigationFormName]![NavigationSubform].Form.Locked=False

**
there is only 1 Navigation subform for all the tabs.
it just changes it SourceObject.
so locking is global to all tabs.
 

alvingenius

IT Specialist
Local time
Today, 13:26
Joined
Jul 10, 2016
Messages
169
Hi. I'm not sure I understand your question. If you disable the subform, it shouldn't also disable the tabs. So, the user should be free to click on the next tab when they want to. At that time, you can disable the subform, so they can work on it.


i've nav form with 5 tabs with 5 subforms linked with em

first tab named "NavProfile" linked to subform named "subProfile"

when i open the main form "frmMain" in the nav form, tab named "NavPofile" is active automatically as it's the first tab

i've managed to disable this tab but the subform linked to it is already opened
that's why i want to disable editing on this subform named "subProfile" linked to tab "NavProfile"

i hope i was able to explain it better now ;)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:26
Joined
Oct 29, 2018
Messages
21,454
i've nav form with 5 tabs with 5 subforms linked with em

first tab named "NavProfile" linked to subform named "subProfile"

when i open the main form "frmMain" in the nav form, tab named "NavPofile" is active automatically as it's the first tab

i've managed to disable this tab but the subform linked to it is already opened
that's why i want to disable editing on this subform named "subProfile" linked to tab "NavProfile"

i hope i was able to explain it better now ;)
Hi. I understand what you're saying but it seems you're not understanding what I am saying. You have five tabs and five forms associated with each one. However, I am saying since you're using a Navigation Form, there is really only one subform control on your form, which displays those five forms depending on which tab you clicked. So, when you click a tab, the subform control displays the appropriate form and when you click on another tab, the subform is replaced by the next one. So, when the subform is displaying the first tab form, either by simply opening the Navigation Form or by clicking on the first tab, you can disable the subform using the code similar to what I gave you earlier. To enable it back for the other tabs, you use the same code but use the True value for the assignment. Hope it makes sense...
 

alvingenius

IT Specialist
Local time
Today, 13:26
Joined
Jul 10, 2016
Messages
169
just put your navigation form in design view.
click on the NavigationSubform.
on its property->data->locked = Yes.

when it's time to unlock:

Forms![NavigationFormName]![NavigationSubform].Form.Locked=False

**
there is only 1 Navigation subform for all the tabs.
it just changes it SourceObject.
so locking is global to all tabs.

is there a way to lock specific tab with specific sourceobject ?


and i can manipulate it with ur idea

since he is on the wrong tab i will lock the whole nav form
then when he click on the other tab then i will enable the nav form again

and he can't click on the first tab anymore since it's disabled

but i'm looking for a simpler idea
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:26
Joined
Oct 29, 2018
Messages
21,454
is there a way to lock specific tab with specific sourceobject ?


and i can manipulate it with ur idea

since he is on the wrong tab i will lock the whole nav form
then when he click on the other tab then i will enable the nav form again

and he can't click on the first tab anymore since it's disabled

but i'm looking for a simpler idea
Hmm, As I said earlier, locking the subform control shouldn't lock the tabs as well. Can you please show us exactly how you're locking the subform that is causing the tabs to get locked as well? Thanks.
 

alvingenius

IT Specialist
Local time
Today, 13:26
Joined
Jul 10, 2016
Messages
169
Hmm, As I said earlier, locking the subform control shouldn't lock the tabs as well. Can you please show us exactly how you're locking the subform that is causing the tabs to get locked as well? Thanks.

i didn't say my tabs is locked because i locked nav form !!

i'll try to simply it more

i've a main form with nav form inside having 5 tabs with 5 linked subforms

first tab is for main profiles and i wanna lock editing it for specific users

rest of tabs is ok to edit subforms inside them by this users

i wanna lock the first tab subform related to it

First tab for read only subform!! and the rest of tabs is allowing adding/edit in subforms related to them

this code
Code:
Forms!frmMain![Navigation Subform].Enabled = False

is locking the whole subforms inside the 5 tabs and that's not what i want

i only wanna lock 1 subform

i hope you get it it now !!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:26
Joined
Oct 29, 2018
Messages
21,454
i didn't say my tabs is locked because i locked nav form !!

i'll try to simply it more

i've a main form with nav form inside having 5 tabs with 5 linked subforms

first tab is for main profiles and i wanna lock editing it for specific users

rest of tabs is ok to edit subforms inside them by this users

i wanna lock the first tab subform related to it

First tab for read only subform!! and the rest of tabs is allowing adding/edit in subforms related to them

this code
Code:
Forms!frmMain![Navigation Subform].Enabled = False
is locking the whole subforms inside the 5 tabs and that's not what i want

i only wanna lock 1 subform

i hope you get it it now !!
Hi. Sorry but that doesn't make sense without seeing your form. The subform control should be separate from the tabs on the Navigation Form, unless you're saying the tabs are also in the subform. To be sure, can you please post a screenshot of your NavForm in design view? Thanks.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:26
Joined
Oct 29, 2018
Messages
21,454
Hi. Sorry but that doesn't make sense without seeing your form. The subform control should be separate from the tabs on the Navigation Form, unless you're saying the tabs are also in the subform. To be sure, can you please post a screenshot of your NavForm in design view? Thanks.
Here's an example of what a Nav Form might look like. Notice the tabs are separate from the selected subform control (bordered by a yellow line = selected). Does yours look like this?
 

Attachments

  • navform.PNG
    navform.PNG
    27.6 KB · Views: 824

alvingenius

IT Specialist
Local time
Today, 13:26
Joined
Jul 10, 2016
Messages
169
Here's an example of what a Nav Form might look like. Notice the tabs are separate from the selected subform control (bordered by a yellow line = selected). Does yours look like this?


No it not like this at my end

if i add a button to navigation form then i have to link it subform !

check my db in design mode and another new test
 

Attachments

  • Untitled.png
    Untitled.png
    80.6 KB · Views: 121
  • Untitled2.png
    Untitled2.png
    49.9 KB · Views: 130

alvingenius

IT Specialist
Local time
Today, 13:26
Joined
Jul 10, 2016
Messages
169
Here's an example of what a Nav Form might look like. Notice the tabs are separate from the selected subform control (bordered by a yellow line = selected). Does yours look like this?

in ur photo u can put anything in FORM1 nav tab i can't !!! as u see in the second photo i've attached i've to choose form target for the nav tab !!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:26
Joined
Oct 29, 2018
Messages
21,454
in ur photo u can put anything in FORM1 nav tab i can't !!! as u see in the second photo i've attached i've to choose form target for the nav tab !!
Hi. That shouldn't matter. Once you have selected the target form, it should still behave as I was describing. Meaning, there is only one subform control where each subform is displayed. When another tab is selected, the previous subform is replaced by the next one.
I thought it might be easier to show it to you, so I created a small demo. Please see attached where you'll see the first tab's subform is disabled, but the second tab is enabled. Hope it helps...
 

Attachments

  • NavFormDemo.zip
    30.7 KB · Views: 112

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:26
Joined
May 7, 2009
Messages
19,233
this is the easiest way.
leave this one as is:

Forms!frmMain![Navigation Subform].Locked = True

now on design view of your form, add code to each navigation button's Click Event, eg:
Code:
Private Sub NavigationButton1_Click()  'supposing this is your first button
Me.NavigationSubform.Form.Locked = True
End Sub
on the other button's click event:
Code:
Private Sub NavigationButton2_Click()
Me.NavigationSubform.Form.Locked = False
End Sub
you do the above with the rest of the buttons.
 

alvingenius

IT Specialist
Local time
Today, 13:26
Joined
Jul 10, 2016
Messages
169
Hi. That shouldn't matter. Once you have selected the target form, it should still behave as I was describing. Meaning, there is only one subform control where each subform is displayed. When another tab is selected, the previous subform is replaced by the next one.
I thought it might be easier to show it to you, so I created a small demo. Please see attached where you'll see the first tab's subform is disabled, but the second tab is enabled. Hope it helps...


this is the easiest way.
leave this one as is:

Forms!frmMain![Navigation Subform].Locked = True

now on design view of your form, add code to each navigation button's Click Event, eg:
Code:
Private Sub NavigationButton1_Click()  'supposing this is your first button
Me.NavigationSubform.Form.Locked = True
End Sub
on the other button's click event:
Code:
Private Sub NavigationButton2_Click()
Me.NavigationSubform.Form.Locked = False
End Sub
you do the above with the rest of the buttons.


Hello

Your ways enabling or disabling Nav subform when clicked on button

but i want it to code permission access

i've a user table lets say with :

PHP:
ID
username
password
accessTab1  Yes/No
accessTab2  Yes/No
accessTab3  Yes/No

and i'm retrieving this table to the main form with Dlookups to check user permissions
and in main form "Current Event" or "Load Event" i'm adding :

Code:
If txtaccesstab1= False Then ' from dlookup 
    Forms!frmMain!Nav1.Enabled = False
Else
    Forms!frmMain!Nav1.Enabled = True
End If

If txtaccesstab2= False Then ' from dlookup 
    Forms!frmMain!Nav2.Enabled = False
Else
    Forms!frmMain!Nav2.Enabled = True
End If

If txtaccesstab3= False Then ' from dlookup 
    Forms!frmMain!Nav3.Enabled = False
Else
    Forms!frmMain!Nav3.Enabled = True
End If

and it works
if i have access to tab2,3 i will see tab1 button disabled but the subform related to it is already opened because it's the first tab

i can't use
Code:
Me.NavigationSubform.Form.Locked = True
in every if conditions because if someone don't have access to tab3 for example the whole nav form will be disabled

i wanted a code to disable SourceObject of the tab but i think it's not possible

what about moving the user to the tab he have access to it ?

like when i open the main form and the user have access to tab2 then in the if condition mentioned above i will add a vba code to switch user to nav tabs !!

is there a vba code to open specific navigation form tabs ?
like creating a button to navigate me to specific navigation form tabs

:eek::eek::eek:
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:26
Joined
May 7, 2009
Messages
19,233
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
 

Users who are viewing this thread

Top Bottom