Hide/unHide control

cpampas

Registered User.
Local time
Today, 12:31
Joined
Jul 23, 2012
Messages
221
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
 
So hide the control to start with?
Or try the OnLoad event.
 
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.
 
You can also tidy up the code with
Code:
Me.cPDF.Visible = InStr(Me.path1, ".pdf") > 0
etc, etc
 

Users who are viewing this thread

Back
Top Bottom