Hide/unHide control (1 Viewer)

cpampas

Registered User.
Local time
Yesterday, 16:08
Joined
Jul 23, 2012
Messages
218
Hello,
I have a form with a control named "cPDF". On the current event of the form I have the following code:
Code:
If InStr(Me.path1, ".pdf") > 0  Then
    Me.cPDF.Visible = True
Else
    Me.cPDF.Visible = False
End If

It shows the control cPDF with the set condition. My problem is when opening the form, the code does not run soon enough to hide/unhide the control.
I tried the same code on different events, onopen, onActivate, with no results.

Any thoughts?
thanks
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:08
Joined
Sep 21, 2011
Messages
14,369
So hide the control to start with?
Or try the OnLoad event.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 18:08
Joined
Feb 28, 2001
Messages
27,243
First, Gasman's advice is correct - either hide the control initially or use OnLoad

Second, be aware that even if the control is invisible, your code doesn't DISABLE the control. The cursor WILL change (according to your Windows Theme settings) based on moving over an active control. Invisible is not equal to inactive. You should consider me.cPdf.Enabled = False (or True) as appropriate AS WELL AS .Visible if you really don't want any interactions with the control under your chosen circumstances.
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:08
Joined
Sep 21, 2011
Messages
14,369
You can also tidy up the code with
Code:
Me.cPDF.Visible = InStr(Me.path1, ".pdf") > 0
etc, etc
 

cpampas

Registered User.
Local time
Yesterday, 16:08
Joined
Jul 23, 2012
Messages
218
Thanks for your response. That worked fine
 

Users who are viewing this thread

Top Bottom