rupes_mahal
08-23-2001, 01:08 AM
Hi..
I have designed a form to insert users details. I have inserted a text box called Note. I want to hide this text box and i only want it to appear when the user clicks on a command button.
How do i do this?
Please help..
Ruby
AndyBannister
08-23-2001, 01:12 AM
Ruby,
The very simplest way to do this is as follows:
1) In design view, set the "visible" property of the text box to "no". Thus when the form opens, it will be hidden.
2) In the ONCLICK event of the command button, write the following code:
note.visible=False
... and voila. The text box will only appear when the user clicks the button.
Hope this helps,
Andy
rupes_mahal
08-23-2001, 01:30 AM
Hi Andy..
it doesnt work. When I click the button, the text box does not appear. The code for the button so far is:
Private Sub NoteButton_Click()
note.Visible = False
End Sub
The text box is hiden when I go into the form, but when I click on the command button, it does not appear..
help...
thank u in advance
ruby
AndyBannister
08-23-2001, 02:39 AM
My fault --- typed the reply in a hurry.
Should be:
note.visible=true
Doh!
rupes_mahal
08-23-2001, 02:53 AM
Andy..
Got it....its all working..
One other problem:
I have a button which hides the "Note text box". The Text box and the close note button both appear when I click on the "Note Button".
So the text box and the close button appear. I enter in my text. Then I want to hide or close the text box AND the close button. But it doesnt work. When I click on the close note button, it hides the text box, but not the close button. Error message appearing:
""run-time error 221652
You can't hide a control that has the focus.""
The code in the "Close button" :
Private Sub CloseNote_Click()
note.visible = False
closeNote.visible = false
end sub
The error message highlights the "closeNote.visible = false" line in the code.
How can I hide the close note button?
Ruby
Thanku in advance
AndyBannister
08-23-2001, 03:02 AM
The problem is that when you click on the Close Button, that control gets the focus ... and as you cannot hide a control with the focus, when you run your code to hide that button, lo and behold an error occurs
What you need to do is insert a line that reads:
docmd.gotocontrol "<control name>"
before the CloseButton.Visible=false command
Replace <control name> with the name of any visible control on your form. Then when the user clicks the Close button, the focus will first shift off the Close button, allowing Access to hide it.
That should work.
rupes_mahal
08-23-2001, 03:08 AM
Andy....u are a darling
Thankyou very much.
I wouldn't have thought of that myself.
Your help is very much appreciated
Ruby
jwindon
08-24-2001, 03:20 PM
Hide and go seek with the controls ! How cool! Think I'll try that out myself...say AfterUpdate, PaymentReceivedDate, CheckNo.Visable=True.
That will save a lot of time. I wonder, Does the tab order throw out all "hidden" controls? Think I'll check that out.