How to hide checkbox and label on a form

botci

Registered User.
Local time
Today, 09:53
Joined
Feb 28, 2017
Messages
18
Hello all!

I have inherited an incomplete project, with a limited knowledge to Access and VBA, please help.

I have a form, called "validalist". There is a checkbox named "Arch" in the header. I want to hide or reappear another checkbox named "Arch2" and a label "label1" with checking or unchecking "Arch".

I tried a little code like this:

Code:
If Me.Arch = True Then

 Validalist.[Arch2].visible = False        
       
Else
        
 Validalist.[Arch2].visible = True
       
End If
But I get "Object doesn't support this property or method"
How to write this code properly?
 
Your referencing the Control using

Validalist.[Arch2]

is incorrect syntax. The simplest way to do it, is to use Me., as in

Code:
Private Sub Arch_AfterUpdate()
 
 If Me.Arch = True Then
  Me.Arch2.Visible = False
  Me.Label1.Visible = False
 Else
  Me.Arch2.Visible = True
  Me.Label1.Visible = True
 End If

End Sub

as you did in your first line of code. If this needs to be record appropriate (as you move from record to record) you'll also need the same code in the Form_Current event.

Linq ;0)>
 
Thank you, yes it works!

Another little problem, that I'd like "Arch2" and "Label1" hidden by default when I open this form. :

Code:
Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "validalaslist"
    stLinkCriteria = "[Arch] = false"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Me.label1.visible = False
It says "Object required"
What is the right syntax?
 
In validalaslist itself, either set their Visible Properties to No, in the Properties Pane or, in the Form_Load event, use

Code:
Private Sub Form_Load()
  Me.Arch2.Visible = False
  Me.Label1.Visible = False
End Sub
Just open the Form using

DoCmd.OpenForm stDocName

Linq ;0)>
 
Thank you, setting their Visible Properties to No worked!

Opening the Form using just

DoCmd.OpenForm stDocName

didn't work, but the point is my problem solved :-)
 

Users who are viewing this thread

Back
Top Bottom