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 / General 1 / January 2006

Tip: Looking for answers? Try searching our database.

enable controls on tab control form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
david.boone@acgov.org - 12 Jan 2006 19:25 GMT
Hello,

I am trying to enable controls based on the value of a checkbox, i.e.
if value = true then enable.

I have a tab control form with controls on 4 tabs.  I have some code
(below) on the tab control "on change" event.

This works for the 'first tab' but then does not work for any other
tab.

Any ideas?

Thanks!

Dave

Private Sub TabCtlPage2_Change()

CmdExit.SetFocus
'set the focus to exit button

Select Case TabCtlPage2.Value

Case Is = 1

 For Each c In Me.Controls

   If c.Tag = "PREABY" Then
     c.Enabled = Nz(Me.checkbox_PREABY.Value, True)
   End If

   If c.Tag = "PREOBC" Then
     c.Enabled = Nz(Me.checkbox_PREOBC.Value, True)
   End If

   If c.Tag = "PREMT" Then
     c.Enabled = Nz(Me.checkbox_PREMT.Value, True)
   End If

   If c.Tag = "PREPMCT" Then
     c.Enabled = Nz(Me.checkbox_PREPMCT.Value, True)
   End If

 Next

Case Is = 2

  For Each c In Me.Controls

   If c.Tag = "CAROVC" Then
     c.Enabled = Nz(Me.checkbox_CAROVC.Value, True)
   End If

   If c.Tag = "CARVCT" Then
     c.Enabled = Nz(Me.checkbox_CARVCT.Value, True)
   End If

   If c.Tag = "CARPCBH" Then
     c.Enabled = Nz(Me.checkbox_CARPCBH.Value, True)
   End If

   If c.Tag = "CARPCTH" Then
     c.Enabled = Nz(Me.checkbox_CARPCTH.Value, True)
   End If

  Next

 Case Is = 3

  For Each c In Me.Controls

   If c.Tag = "TREART" Then
     c.Enabled = Nz(Me.checkbox_TREART.Value, True)
   End If
  Next
End Select
End Sub
Tim Marshall - 12 Jan 2006 19:46 GMT
> This works for the 'first tab' but then does not work for any other
> tab.

This is because your code is using a select statement to check what the
value of TabCtlPage2.Value is.  In other words, what is the currently
displayed page for the tab control.  The case statements then do your
stuff for the controls inbdicated.

Get rid of the select statement and list all the if statements one after
the other.  Then they will all be run when the tab chnages.

Signature

Tim    http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto  "TIM-MAY!!" - Me

david.boone@acgov.org - 12 Jan 2006 21:13 GMT
Thanks, that does work but I had to copy and paste all the controls and
the OnChange code into a new form.  I think I had some other code
somewhere that was preventing me from accessing the other tabs in the
tab control.

thanks again,

Dave
 
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.