473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

VBA - Showing / Hiding Textbox

daoxx
32
Hello
I've searched, posted and solved this (Thanks for helping!), but now it came back to bite me in the *ss.

I have a Yes/No field that is represented by a check box in my form1.
I want to show another field (textbox) when the mouse pointer goes over the checkbox, and make it not visible when the mouse moves away from it.

My problem is that when I make the textbox diseappear, if the user set focus on it and moves the mouse away, Access gives me a "Can't hide a control while it has focus" error.

My question is: How can I resolve this problem?

I later added this: text2.SetFocus

I need to set focus on something else, but I can't do with the "when mouse moves on top of the form's background" thing, because then whenever the user moved the mouse on the background, the focus would be set to the same thing, i.e. user types in something to text1 (show/hide textbox) and then wants to change text3 (visible), but can't move the mouse because the focus would be set to text2.

This is the code I used:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Chck1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2. text1.Visible = True
  3. End Sub
  4.  
  5. Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  6. text1.Visible = False
  7. End Sub
I will appreciate any help possible,
Thank you
Mar 31 '08 #1
10 10430
JConsulting
603 Expert 512MB
Hello
I've searched, posted and solved this (Thanks for helping!), but now it came back to bite me in the *ss.

I have a Yes/No field that is represented by a check box in my form1.
I want to show another field (textbox) when the mouse pointer goes over the checkbox, and make it not visible when the mouse moves away from it.

My problem is that when I make the textbox diseappear, if the user set focus on it and moves the mouse away, Access gives me a "Can't hide a control while it has focus" error.

My question is: How can I resolve this problem?

I later added this: text2.SetFocus

I need to set focus on something else, but I can't do with the "when mouse moves on top of the form's background" thing, because then whenever the user moved the mouse on the background, the focus would be set to the same thing, i.e. user types in something to text1 (show/hide textbox) and then wants to change text3 (visible), but can't move the mouse because the focus would be set to text2.

This is the code I used:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Chck1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2. text1.Visible = True
  3. End Sub
  4.  
  5. Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  6. text1.Visible = False
  7. End Sub
I will appreciate any help possible,
Thank you
Outside the box...

create an unbound textbox or just a box that matches your background and large enough to cover up the Textbox in question. Make IT visible or invisible on top of your Textbox to "hide" it.
Apr 1 '08 #2
daoxx
32
What if the textboxes that I need to hide are partially stacked? The boxes would either cover more than necessary, or show more than necessary.
Apr 1 '08 #3
mshmyob
904 Expert 512MB
I may be missing something here because I don't know what you mean about the 'form background' thing.

But assuming you have a checkbox (chkControlName) and say 2 text boxes on the form (txtName1 and txtName2). When mouse moves over checkbox it will display txtName1. After losing focus on txtName1 it will setfocus to txtName2 and hide txtName 1 again.

In the MouseMove event of chkControlName
Expand|Select|Wrap|Line Numbers
  1. Me.txtName1.Visible = True
  2.  

In the LostFocus event of txtName1
Expand|Select|Wrap|Line Numbers
  1. Me.txtName2.SetFocus
  2. Me.txtName1.Visible = False
  3.  

Does this help?

cheers,

Hello
I've searched, posted and solved this (Thanks for helping!), but now it came back to bite me in the *ss.

I have a Yes/No field that is represented by a check box in my form1.
I want to show another field (textbox) when the mouse pointer goes over the checkbox, and make it not visible when the mouse moves away from it.

My problem is that when I make the textbox diseappear, if the user set focus on it and moves the mouse away, Access gives me a "Can't hide a control while it has focus" error.

My question is: How can I resolve this problem?

I later added this: text2.SetFocus

I need to set focus on something else, but I can't do with the "when mouse moves on top of the form's background" thing, because then whenever the user moved the mouse on the background, the focus would be set to the same thing, i.e. user types in something to text1 (show/hide textbox) and then wants to change text3 (visible), but can't move the mouse because the focus would be set to text2.

This is the code I used:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Chck1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2. text1.Visible = True
  3. End Sub
  4.  
  5. Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  6. text1.Visible = False
  7. End Sub
I will appreciate any help possible,
Thank you
Apr 1 '08 #4
daoxx
32
By "form background" I meant the part named "Detail", sorry :P

Yea, I was missing the LostFocus thingie.. Thanks.
Only problem now is that if the user passes the mouse pointer over the checkbox, the textbox1 will pop-up and not go away until the user clicks it (set focus on it) and then clicks some other textbox.

Is there anyway to control this? Perhaps a timer that does a condition where if the user does not set focus on the textbox1 after some time, it will disappear?
(I've no idea if you can do that)

Thanks for helping
Apr 1 '08 #5
mshmyob
904 Expert 512MB
Yes you can do that. You can setfocus to text1 if you want after moving the mouse over the checkbox (don't know if you want that though).

I will do the timer thing later today for you , I have to go see a client right now.

cheers,

By "form background" I meant the part named "Detail", sorry :P

Yea, I was missing the LostFocus thingie.. Thanks.
Only problem now is that if the user passes the mouse pointer over the checkbox, the textbox1 will pop-up and not go away until the user clicks it (set focus on it) and then clicks some other textbox.

Is there anyway to control this? Perhaps a timer that does a condition where if the user does not set focus on the textbox1 after some time, it will disappear?
(I've no idea if you can do that)

Thanks for helping
Apr 1 '08 #6
daoxx
32
Thanks! Seriously, thank you :D
It'll help me alot.

Yes you can do that. You can setfocus to text1 if you want after moving the mouse over the checkbox (don't know if you want that though).

I will do the timer thing later today for you , I have to go see a client right now.

cheers,
Apr 1 '08 #7
mshmyob
904 Expert 512MB
Ok same scenario as before but I added a timer event. When you move over the check box TEXT1 will display for a set period of time if it does not have focus. If it has focus it will stay displayed. When you move off of it it will disappear again.

This goes in the MouseMove event of the check box
Expand|Select|Wrap|Line Numbers
  1. ' show your text box if mouse moves over the checkbox
  2. Me.Text1.Visible = True
  3. 'start the timer event for a specified amount of time (increase for more time)
  4. Me.Form.TimerInterval = 2000
  5.  
This goes in the OnTimer event of the Form
Expand|Select|Wrap|Line Numbers
  1. ' determine if we are in the text box
  2. ' if so do nothing until we lose focus
  3. If Me.ActiveControl.name = "Text1" Then
  4.             'do nothing
  5. Else
  6.             Me.Text1.Visible = False
  7.             Me.Form.TimerInterval = 0
  8. End If
  9.  
Remove everything from the LostFocus event of Text1 (as from the previous code example)

cheers,


Thanks! Seriously, thank you :D
It'll help me alot.
Apr 1 '08 #8
daoxx
32
Thank you so much!
Although I don't have the possibility to test it right now, I'll say something when I can.

Thanks
Apr 2 '08 #9
daoxx
32
Yes, it works perfectly! Thank you :)
If only I could give you some kind of expert points :d

Thanks
Apr 3 '08 #10
mshmyob
904 Expert 512MB
You're welcome. Being able to help is good enough for me.

cheers,

Yes, it works perfectly! Thank you :)
If only I could give you some kind of expert points :d

Thanks
Apr 3 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: c.anandkumar | last post by:
Hi All - I have some problems getting a small piece of javascript working correctly for Firefox. Here is what I am trying to do - 1. I have a form (like a search form) 2. I have many groups...
1
by: Alexander | last post by:
I am building a little unique dialog editor and have derived some new classes like DButton, DLabel and DTextBox. The user adds these Controls to a panel which is part of a class Document which is...
1
by: Dan Neely | last post by:
I want to have my textbox display a scrollbar if there is more text than will fit, but to make it invisible if it will all fit. Is this possible? The default behavior if all the text fits is a...
1
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems...
4
by: beccak | last post by:
Hi, I'm trying to hide a template column in a datagrid then later show it. I've tried setting the visibility to false, but this doesn't let me get to the underlying data in the column. I've tried...
3
by: Charlie Dison | last post by:
Hi There, Should I be able to show and hide panels in an asp.net page without requiring a postback? I thought there was a way to do this using java script. Can anyone give me an example? I...
7
by: Mike9900 | last post by:
I am inheriting from a text box control and does not want the client see some of the methods be invisible to the clients. Mike
2
by: =?Utf-8?B?Sm9zaCBTY2htaWR0?= | last post by:
I have a gridview that is being used for managing inventory. The default view shows the stock currently available. When editing I don't want the stock to be directly edited, rather the user will...
9
daoxx
by: daoxx | last post by:
Hi Question#1 Is it possible to show a textbox (linked to a field) when the mouse pointer goes over a checkbox, and hiding it when the pointer goes away, and at the same time allowing the user to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.