Minggu, 03 November 2013

[MS_AccessPros] RE: tab control question

 

You can show/hide tables using the index or better still  tab names. I prefer using names because tabs can move positions/index. Below is a code I use in one of our database in OnCurrent event. You can use a similar process fro any event.

 

Private Sub Form_Current()
On Error GoTo Err_Form_Current

    DisplayActiveName
   
    'Show/hide work history and Additional Non_Centre Details tabs
    If IsNull(Me!chkStaffMember) Then
     'Display tabWorkHistory, tbStudy and tabAdditionalNonCentreDetails pages
        Me!tabStaff.Pages("tabStudy").Visible = True
        Me!tabStaff.Pages("tabWorkHistory").Visible = True
        Me!tabStaff.Pages("tabAdditionalNonCentreDetails").Visible = True
    Else
        'Only display relevant pages
        If Me!chkStaffMember Then
            Me!frmStaffPositions.Visible = True
            Me!txtPosition.Visible = True
            Me!tabStaff.Pages("tabStudy").Visible = True
            Me!tabStaff.Pages("tabWorkHistory").Visible = True
            Me!lblPosition.Visible = False
            Me!Position.Visible = False
            Me!cmdPositionMaintenance.Visible = True
            Me!tabStaff.Pages("tabAdditionalNonCentreDetails").Visible = False
           
            'Set controls locations
            Me!lblCompanyUnit.Left = 2.937 * conTWIPS
            Me!CompanyUnit.Left = 5.39 * conTWIPS
            Me!CompanyUnit.Width = 14.801 * conTWIPS
           
            'Staff
            Me!lblAddress.Top = 7.037 * conTWIPS
            Me!Address.Top = 7.037 * conTWIPS
            Me!lblTownCity.Top = 8.783 * conTWIPS
            Me!TownCity.Top = 8.783 * conTWIPS
            Me!lblState.Top = 8.783 * conTWIPS
            Me!cmbState.Top = 8.783 * conTWIPS
            Me!lblPostcode.Top = 8.783 * conTWIPS
            Me!Postcode.Top = 8.783 * conTWIPS
            Me!lblCountry.Top = 9.55 * conTWIPS
            Me!cmbCountry.Top = 9.55 * conTWIPS
            Me!lblEmail.Top = 9.55 * conTWIPS
            Me!Email.Top = 9.55 * conTWIPS
            Me!lblComments.Top = 10.397 * conTWIPS
            Me!Comments.Top = 10.397 * conTWIPS
            Me!Comments.Height = 2.2 * conTWIPS
           
            'Setup Work History objects
            'SetupWorkHistoryObjects
           
            'Show staff warnings
            Me!lblWarning1.Visible = True
            Me!warningbox1.Visible = True
            Me!lblWarning2.Visible = True
            Me!WarningBox2.Visible = True
            Me!lblWarning3.Visible = True
            Me!WarningBox3.Visible = True
       Else
            Me!lblPosition.Visible = True
            Me!Position.Visible = True
            Me!frmStaffPositions.Visible = False
            Me!txtPosition.Visible = False
            Me!cmdPositionMaintenance.Visible = False
            Me!tabStaff.Pages("tabStudy").Visible = False
            Me!tabStaff.Pages("tabWorkHistory").Visible = False
            Me!tabStaff.Pages("tabAdditionalNonCentreDetails").Visible = True
           
            'Set controls locations
            Me!lblCompanyUnit.Left = 10.9 * conTWIPS
            Me!CompanyUnit.Left = 13.296 * conTWIPS
            Me!CompanyUnit.Width = 6.915 * conTWIPS
           
            'Non-Staff
            Me!lblAddress.Top = 2.6 * conTWIPS
            Me!Address.Top = 2.6 * conTWIPS
            Me!lblTownCity.Top = 4.19 * conTWIPS
            Me!TownCity.Top = 4.19 * conTWIPS
            Me!lblState.Top = 4.19 * conTWIPS
            Me!cmbState.Top = 4.19 * conTWIPS
            Me!lblPostcode.Top = 4.19 * conTWIPS
            Me!Postcode.Top = 4.19 * conTWIPS
            Me!lblCountry.Top = 4.998 * conTWIPS
            Me!cmbCountry.Top = 4.998 * conTWIPS
            Me!lblEmail.Top = 4.998 * conTWIPS
            Me!Email.Top = 4.998 * conTWIPS
            Me!lblComments.Top = 5.799 * conTWIPS
            Me!Comments.Top = 5.799 * conTWIPS
            Me!Comments.Height = 6.8 * conTWIPS

            'Hide staff warnings
            Me!lblWarning1.Visible = False
            Me!warningbox1.Visible = False
            Me!lblWarning2.Visible = False
            Me!WarningBox2.Visible = False
            Me!lblWarning3.Visible = False
            Me!WarningBox3.Visible = False
       End If
    End If 

...

 
I hope that will help you with your project.
 
John
 
---In MS_Access_Professionals@yahoogroups.com, <ms_access_professionals@yahoogroups.com> wrote:

I am using a tab control on a main form.  The tab control has 8 pages.  Some of the pages are hidden and will only be made visible based on a control on one of the other pages.  Is there an easy way to turn the visible on and off easily with in vba using the event method? 

I think I am missing something in the command sequence.

Rod

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar