Hide / show subform (1 Viewer)

Gismo

Registered User.
Local time
Today, 23:20
Joined
Jun 12, 2017
Messages
1,298
Hi all,

How do I adapt below code if I moved the subform from another subform into the main form?

If IsNull(Me.DefectAdditionalWork) Or (IsNull(Me.Location)) Or (IsNull(Me.RaiseCS)) Or (IsNull(Me.IntExt)) Then
Me.SavePlanningMisc.Visible = False
Else
Me.SavePlanningMisc.Visible = True
End If
Me.Requery
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:20
Joined
May 7, 2009
Messages
19,231
where is this code belong? main form?
 

Gismo

Registered User.
Local time
Today, 23:20
Joined
Jun 12, 2017
Messages
1,298
where is this code belong? main form?
This is on the sub form
If IsNull(Me.DefectAdditionalWork) Or (IsNull(Me.Location)) Or (IsNull(Me.RaiseCS)) Or (IsNull(Me.IntExt)) Then

Below is a subform on the main form

Me.SavePlanningMisc.Visible = False
Else
Me.SavePlanningMisc.Visible = True
End If

I have 2 sub forms on the main form
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:20
Joined
May 7, 2009
Messages
19,231
Code:
If IsNull(Me.DefectAdditionalWork) Or (IsNull(Me.Location)) Or (IsNull(Me.RaiseCS)) Or (IsNull(Me.IntExt)) Then
Me.Parent!SavePlanningMisc.Form.Visible = False
Else
Me.Parent!SavePlanningMisc.Form.Visible = True
End If
Me.Requery
 

Gismo

Registered User.
Local time
Today, 23:20
Joined
Jun 12, 2017
Messages
1,298
Code:
If IsNull(Me.DefectAdditionalWork) Or (IsNull(Me.Location)) Or (IsNull(Me.RaiseCS)) Or (IsNull(Me.IntExt)) Then
Me.Parent!SavePlanningMisc.Form.Visible = False
Else
Me.Parent!SavePlanningMisc.Form.Visible = True
End If
Me.Requery
1644396295688.png


If IsNull(Me.DefectAdditionalWork) Or (IsNull(Me.Location)) Or (IsNull(Me.RaiseCS)) Or (IsNull(Me.IntExt)) Then
Me.[DAWSheet_MainMisc]![SavePlanningMisc].Form.Visible = False
Else
Me.[DAWSheet_MainMisc]![SavePlanningMisc].Form.Visible = True
End If
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:20
Joined
May 7, 2009
Messages
19,231
which line has the error? can you add breakpoint.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:20
Joined
May 7, 2009
Messages
19,231
You can't refer to the subform on another main form using that syntax.
see post #3.
there are 2 subforms on main form.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:20
Joined
May 7, 2009
Messages
19,231
can you just use Parent, instead of the mainform name:

Me.Parent!SavePlanningMisc.Form.Visible = False
 

Gismo

Registered User.
Local time
Today, 23:20
Joined
Jun 12, 2017
Messages
1,298
can you just use Parent, instead of the mainform name:

Me.Parent!SavePlanningMisc.Form.Visible = False
The parent is the main form in this case, not so?
DAWSheet_MainMisc s the main form
Subform 1 - SavePlanningMisc
The form I am running the code from, subform 2, is DAWSheetMainMiscSub

If not all the criteria has been completed in the 2nd for, the f1st subform should not be visible

Me.[DAWSheet_MainMisc]![SavePlanningMisc].Form.Visible = False
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:20
Joined
May 7, 2009
Messages
19,231
on design view Click on the "border" of the subform in question.
make sure a "yellow" line surrounds the subform when you clicked on it.
now, goto property window, on Tab "Other", what Name do you see.
use that name.
 

Gismo

Registered User.
Local time
Today, 23:20
Joined
Jun 12, 2017
Messages
1,298
on design view Click on the "border" of the subform in question.
make sure a "yellow" line surrounds the subform when you clicked on it.
now, goto property window, on Tab "Other", what Name do you see.
use that name.
SavePlanningMisc

1644398549162.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:20
Joined
May 7, 2009
Messages
19,231
can you post the mainform and the 2 subforms (without table).
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:20
Joined
May 7, 2009
Messages
19,231
from what you described earlier, the two Subs are 1 on top and below (which has sub-subform)?
 

Minty

AWF VIP
Local time
Today, 21:20
Joined
Jul 26, 2013
Messages
10,366
That's two subforms in a subform.

Where are you trying to run this from the MAIN outer form or the first level down subform?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:20
Joined
May 7, 2009
Messages
19,231
can you upload the 3 forms involved (without any table)?
 

Gismo

Registered User.
Local time
Today, 23:20
Joined
Jun 12, 2017
Messages
1,298
can you upload the 3 forms involved (without any table)?
Hi,

I managed to get it working

I moved the code back to the main form with reference from the 2nd sub form on the main form
I now validate the records on the main form

Thank you for the assistance

If IsNull(Me.DefectAdditionalWork) Or (IsNull(Me.Location)) Or (IsNull(Me.RaiseCS)) Or (IsNull(Me.IntExt)) Then
Me.SavePlanningMisc.Visible = False
Else
Me.SavePlanningMisc.Visible = True
End If
Forms![DAWSheet_MainMisc]![SavePlanningMisc].Form.Requery
 

Users who are viewing this thread

Top Bottom