[AccessD] How To Make All Controls on a Form Invisible --THANKS!

Bob Gajewski rbgajewski at roadrunner.com
Fri Mar 29 20:52:33 CDT 2013


Brad

I use the follow code in many forms for resetting/initializing values. You
could certainly adapt it to make visible or hide controls by type.

Bob Gajewski

Private Sub cmdResetAll_Click()
On Error GoTo Err_cmdResetAll_Click

' Set default focus
    frmSelectRecords.SetFocus

' Initialize fields
    Dim I As Integer
    For I = 0 To Me.Count - 1
        If TypeOf Me(I) Is TextBox Then
            Me(I).Value = Null
        ElseIf TypeOf Me(I) Is ComboBox Then
            Me(I).Value = Null
        ElseIf TypeOf Me(I) Is CheckBox Then
            Me(I) = False
            Me(I).Enabled = True
        ElseIf TypeOf Me(I) Is OptionGroup Then
            Me(I).Value = Null
        End If
    Next I

' Set default report parameters
    frmSelectRecords = 1
    frmSortOrder = 1
    frmSortOrder.Enabled = True
    frmReportType = 1
    frmReportType.Enabled = True
    strWhere = ""
    strSortOrder = ""
    strReportName = ""

Exit_cmdResetAll_Click:
    Exit Sub

Err_cmdResetAll_Click:
    MsgBox Err.Description
    Resume Exit_cmdResetAll_Click

End Sub 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Brad Marks
Sent: Friday, March 29, 2013 17:41 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] How To Make All Controls on a Form Invisible
--THANKS!

Jim, Jack, Paul,

Thanks for the help with this question.

I now have a working example.

I appreciate the assistance.

You guys are great!

Brad

  

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Paul Hartland
Sent: Friday, March 29, 2013 4:30 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] How To Make All Controls on a Form Invisible

I usually loop through the controls, just done a quick test created a form
called Form1, then added three buttons named Button1, Button2, Button3 and
put the following code in the open event,

    Dim ctrls As Control
    For Each ctrls In Forms("Form1").Controls
        If ctrls.Name = "Button2" Then
            Me(ctrls.Name).Visible = False
        End If
    Next

Paul





On 29 March 2013 21:25, Jim Dettman <jimdettman at verizon.net> wrote:

>
>   You can do it by section:
>
>    Me.Detail0.Visible = False
>
>  Otherwise, you'll need to loop through the forms control collection.
>
> Jim.
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Brad Marks
> Sent: Friday, March 29, 2013 04:59 PM
> To: Access Developers discussion and problem solving
> Subject: [AccessD] How To Make All Controls on a Form Invisible
>
> All,
>
> We have an Access 2007 application that has a form which contains many 
> controls (buttons).
>
> This application is now going to be placed on a PC where the user is 
> only suppose to see only 1 button.
>
> Is there an easy way in VBA to make all buttons on the form invisible.
> (This would be followed by a single line of code to make the single 
> button visible for this specific user.)
>
> Thanks,
> Brad
>
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>



--
Paul Hartland
paul.hartland at googlemail.com
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list