Subform Enabled / disabled (1 Viewer)

smtazulislam

Member
Local time
Today, 02:09
Joined
Mar 27, 2020
Messages
806
Hi,
I have a parent form what name is "frmEmployeeEdit". In the form have Tab Control 8 pages.
Some pages have Subform and some pages have Continuous Forms.
Exp:
One page name is "EmployeeIdentity_Page" and this page subform name is "PassportSubform"
Two page name is "Facility_Page" and this page Continuous Form name is "FacilitiesSubformEdit"
I try:
Code:
Forms![frmEmployeeEdit]![PassportSubform].EnableD = False
And next try:
Code:
Forms![frmEmployeeEdit]![PassportSubform].Visible= False
it is work, but I dont want to hide fields. Showed and should be gray colors.

I want to enable and disabled Subform fields and Continuous Form fields ?
Thanks and any help will appreciated.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:09
Joined
May 7, 2009
Messages
19,230
you can passed a (0 or False) to these form property:
AllowAdditions
AllowEdits
AllowDeletions


Code:
    With [Forms]![frmEmployeeEdit]![PassportSubform].Form
        .AllowAdditions = False
        .AllowEdits = False
        .AllowDeletions = False
    End With

or simply
Code:
Forms![frmEmployeeEdit]![PassportSubform].Form.Enabled = False
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:09
Joined
Feb 19, 2013
Messages
16,605
think you will need multiple lines, one for each control on the subform - or use a loop in some way. To reference a control on a subform you would have something like

Forms![frmEmployeeEdit]![PassportSubform].form.mycontrol.Enabled = False
 

smtazulislam

Member
Local time
Today, 02:09
Joined
Mar 27, 2020
Messages
806
Thank you so much for reply.
Actually I have a function DisbaleData and EnabledData
I try Disabled Data
Code:
Private Sub DisabledData()
    'Facility
    Me.FacilitiesSubformEdit.EnableD = False

    'Page
'    Me.PassportSubform.EnableD = False
    With [Forms]![frmEmployeeEdit]![PassportSubform].Form
        .AllowAdditions = False
        .AllowEdits = False
    End With
'try it also
    'Forms![frmEmployeeEdit]![PassportSubform].Form.EnableD = False
'try it also
    'Forms![frmEmployeeEdit]![PassportSubform].Form.TabCtlEdit.EnableD = False
    
End Sub
I try Enabled Data
Code:
Private Sub EnableData()
    'Facility
    Me.FacilitiesSubformedit.EnableD = True
    
    'Page
    With [Forms]![frmEmployeeEdit]![PassportSubform].Form
       .AllowAdditions = True
        .AllowEdits = True
    End With
'try it also
'    Forms![frmEmployeeEdit]![PassportSubform].Form.TabCtlEdit.EnableD = True
'try it also
'    Me.PassportSubform.Form.CommandEnabled = True
End Sub
But in this Subform can visible all field. And looking
 

Dreamweaver

Well-known member
Local time
Today, 00:09
Joined
Nov 28, 2005
Messages
2,466
I use this on my main form when I want to prevent editing of a Sub form

Me.SubFormName.Form.AllowEdits = False
 

smtazulislam

Member
Local time
Today, 02:09
Joined
Mar 27, 2020
Messages
806
I use this on my main form when I want to prevent editing of a Sub form

Me.SubFormName.Form.AllowEdits = False
Thank you so much Mick
Not work... And not error.
I can visible all fields after code.
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:09
Joined
Sep 21, 2011
Messages
14,260
Thank you so much Mick
Not work... And not error.
I can visible all fields after code.
You asked for enable/disable originally?

Now you are asking for visible/hidden ?
 

smtazulislam

Member
Local time
Today, 02:09
Joined
Mar 27, 2020
Messages
806
You asked for enable/disable originally?

Now you are asking for visible/hidden ?
oh No, I think you misunderstood me.
I wrote what I found there. All of the fill is hidden. But i dont like to hide these fields.
1604306177091.png

Please look this screenshot Form, "Passport Details" fields can insert curser. And white color.
I wanting subform fields are enabled and grayed color.
Hope you understand me what I looking.
Thank you.
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:09
Joined
Sep 21, 2011
Messages
14,260
What is wrong with CJ_London's solution in post #3?
How have you disabled the controls on the bottom of that form?
 

smtazulislam

Member
Local time
Today, 02:09
Joined
Mar 27, 2020
Messages
806
How have you disabled the controls on the bottom of that form?
Thank you so much for reply

me.fieldName.enabled = false
Because it is the form fields. Top all of the field is a subform. And I looking SubForm and Continuous form.
Post #3:
I try
Forms![frmEmployeeEdit]![PassportSubform].Form.TabCtlEdit.EnableD = False
Not work.
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:09
Joined
Sep 21, 2011
Messages
14,260
So do the same for the other controls? the actual data entry controls, not all the tabs and pages.?
 

Users who are viewing this thread

Top Bottom