Hide / View Controls (1 Viewer)

Gismo

Registered User.
Local time
Today, 22:02
Joined
Jun 12, 2017
Messages
1,298
Hi, Please assist,

I have the following fields that is either hidden or visible depending on a selection made on a combo box (MM03). the selection is on one tab and the hidden / visible fields are on a different tab. then combo is selected, the field that should display is not visible until I press F5 to refresh page. even though i have refreshed in the code.

Code:
If Me.MM03 = "Military" Then
      Me.CP.Visible = True
      Me.EUC.Visible = True
      Me.EXP.Visible = True
      Me.IMP.Visible = True
      Me.CPAttachment.Visible = True
      Me.EUCAttachment.Visible = True
      Me.EXPAttachment.Visible = True
      Me.IMPAttachment.Visible = True
      Me.LabelA.Visible = True
      Refresh
    Else
      Me.CP.Visible = False
      Me.EUC.Visible = False
      Me.EXP.Visible = False
      Me.IMP.Visible = False
      Me.CPAttachment.Visible = False
      Me.EUCAttachment.Visible = False
      Me.EXPAttachment.Visible = False
      Me.IMPAttachment.Visible = False
      Me.LabelA.Visible = False
      Refresh
     End If
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:02
Joined
Sep 21, 2011
Messages
14,237
That should be Me.Refresh?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 20:02
Joined
Feb 19, 2013
Messages
16,609
try me.requery rather than refresh

and your code could be simpler

Me.CP.Visible = Me.MM03 = "Military"
Me.EUC.Visible = Me.MM03 = "Military"
Me.EXP.Visible = Me.MM03 = "Military"



or

Me.CP.Visible = Me.MM03 = "Military"
Me.EUC.Visible = Me.CP.Visible
Me.EXP.Visible = Me.CP.Visible



no if required

edit: actually, not sure you need requery either, so long as your code is run in an event
 

Gismo

Registered User.
Local time
Today, 22:02
Joined
Jun 12, 2017
Messages
1,298
I tried all the suggestions, still not visible until F5
 

CJ_London

Super Moderator
Staff member
Local time
Today, 20:02
Joined
Feb 19, 2013
Messages
16,609
that event only runs when a new record is loaded - and you are not loading a new record.

basic stuff - check the code is running

put the code in your MM03 afterupdate event, or an event related to selecting the tab
 

Users who are viewing this thread

Top Bottom