Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple 'Onclick' request

Status
Not open for further replies.

Lukey

Technical User
Jul 5, 2000
103
GB
If anyone can help me, I would be very grateful.

I have a form with three tabs and some information outside of the tabs. I wish to hide the other information when the 3rd tab is clicked as it doesn't refer to that tab.

This is probably really simple, but it is driving me crazy...

Thanks
 
If you have a subform in your tab page then you can call the subform's enter event from the main form, then make the controls on the main form invisible and/or disabled. You could then make the controls visible on the subform's exit event. If you have tab pages without a subform, you could make the main form controls invisible/disabled when the first control on the 3rd tab has focus.
 
Thanks Omega, that sounds exactly like what I want to do. I do have a subform on the 3rd tab. Is there any chance that you could give me a little more detail ? I know my way around access, but my coding knowledge is rubbish.

Thanks
 
Ok, here is an example. Let's say your third tab has the subform name of frmAccounts and you have a text box on the main form named Text1. I hope this helps. You can access the subform events on the main form left drop down in the code window. Or you can just go to the subform's (not the tab page) property sheet on the page tab...I think there are only 2 events you can call...enter and exit.


Private Sub frmAccounts_Enter()
Me.Text1.Visible = False
End Sub

Private Sub frmAccounts_Exit(Cancel As Integer)
Me.Text1.Visible = True
End Sub
 
Omega !
You are a god !! That was exactly what I was looking for and it works a treat. Sorry if it was a stupidly simple one.. At least now I have learnt something new...

Just out of interest (hope this doesn't sound too silly)

What is the 'Me' bit at the beginning of the code ?

Thanks
 
Me refers to the current object that has focus. Let's say you have a form called frmAccounts and a text box called text1. The syntax for referring to the text box is me.text1 or Me!text1 or Forms!frmAccounts!text1 or me.controls("text1"). Me comes in handy if you may have several forms you could refer to but you only want to refer to the form that currently has focus. It's basically just a shorthand for the complete control reference. A good practice is to use the me modifier.

And I am always learning. When I stop learning then it's time to find another vocation.
 
That explains a lot. Thanks again for your help. I was pulling my hair out over that one...
 
I am having a problem hiding some buttons when i click on them, and i have no idea how to work around it. can some one please help me. this is the code i am using:

Private Sub Save_Click()
On Error GoTo Err_Save_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Save.Visible = False

Exit_Save_Click:
Exit Sub

Err_Save_Click:
MsgBox Err.Description
Resume Exit_Save_Click

End Sub

when i go back into form view, and click on save, it gives me an error message:

you cannot hide a control that has the focus?
 
You can't hidden a control that have the focus:
Me![another control name].SetFocus
Me!Save.Visible = False

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top