Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

Disable/Enable Form Objects With Code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alias - 18 Nov 2005 03:21 GMT
Hello again,

When my form is on a new record, I would like this to happen:

1. Have combo box named FullName be enabled, but all other objects disabled.
2. When FullName is populated, enable all other form objects.

What code do I need to achieve this?

Thanks to all the Access Guru's in advance :-)

-Alias
Marshall Barton - 18 Nov 2005 04:24 GMT
>When my form is on a new record, I would like this to happen:
>
>1. Have combo box named FullName be enabled, but all other objects disabled.
>2. When FullName is populated, enable all other form objects.

First let's identify the controls that you want to disable
by setting their Tag property to PIG.  (Don't forget that
some objects do not have an enabled property and attached
labels will be disabled along with their parent control.)

Use the form's Current event to check for a new record:

Dim ctl As Control
If Me.NewRecord Then
    For each ctl In Me.Controls
        If ctl.Tag = "PIG" Then ctl.Enabled = False
    Next ctl
End If

Use the combo box's AfterUpdate event to enable them:

Dim ctl As Control
If Me.NewRecord And Not IsNull(Me.FullName) Then
    For each ctl In Me.Controls
        If ctl.Tag = "PIG" Then ctl.Enabled = True
    Next ctl
End If

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.