Making a command visible and invisible

A

Alex Martinez

Hi,

I have a form that has a tab control in it. The first tab is called Form
View and has many text boxes so the user can input data. The second tab
called Datasheet view. I am using a subform inside the second tab to get the
datasheet view. My problem is I want to some of my command buttons not be
visible when pressing the datasheet tab. When the user goes back to the Form
View I want the command buttons visible. Below is my code, What am I dong
wrong?, any help will be appreciated. Thank you in advance.

This is on Click event in the Datasheet View tab.

Me.cmdAdd.Visible = True
Me.cmdUndo.Visible = True
Me.cmdDelete.Visible = True

This is on Click event in The Form View tab
Me.cmdAdd.Visible = True
Me.cmdUndo.Visible = True
Me.cmdDelete.Visible = True
 
A

Alex Martinez

Correction the datasheet view tab code I have in Access reads:

Me.cmdAdd.Visible = False
Me.cmdUndo.Visible = False
Me.cmdDelete.Visible = False
 
T

tina

use the *tab control's Change event* instead of the tab page's Click event.
a tab control's Value equals the value of the current tab page's PageIndex
property. so refer to the PageIndex property of each tab page. as an
example, we'll say that the tab control is named TabCtl10, the FormView tab
has a PageIndex of 0 (zero), and the DatasheetView tab has a PageIndex of 1:

Private Sub TabCtl10_Change()

With Me
!cmdAdd.Visible = Not (!TabCtl10 = 1)
!cmdUndo.Visible = Not (!TabCtl10 = 1)
!cmdDelete.Visible = Not (!TabCtl10 = 1)
End With

End Sub

the above acts as a toggle for the command buttons' Visible property. if the
DatasheetView page is the current page, Visible = False, otherwise Visible =
True.

hth
 
Top