VBA - 显示/隐藏文本框 [英] VBA - Showing / Hiding Textbox

查看:903
本文介绍了VBA - 显示/隐藏文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我已经搜索过,发布并解决了这个问题(感谢您的帮助!),但现在它又回来了我的* ss。


我有一个Yes / No字段,由我的form1中的复选框表示。

当鼠标指针移过复选框时,我想显示另一个字段(文本框)当鼠标离开它时不可见。


我的问题是,当我让文本框消失时,如果用户将焦点放在它上面并移开鼠标,Access会给我a当它具有焦点时不能隐藏控件错误。


我的问题是:我该如何解决这个问题?


后来我添加了这个: text2.SetFocus


我需要把注意力集中在别的东西上,但是我不能用当鼠标在表格的背景上移动时。事情,因为每当用户在背景上移动鼠标时,焦点将被设置为相同的东西,即用户键入text1(显示/隐藏文本框),然后想要更改text3(可见),但可以'不要移动鼠标,因为焦点会设置为text2。


这是我使用的代码:

展开 | 选择 | Wrap | 行号

解决方案


您好

我已搜索,发布和解决这(感谢您的帮助!),但现在它回来在* ss中咬我。


我有一个Yes / No字段,由我的form1中的复选框表示。

I想要在鼠标指针移过复选框时显示另一个字段(文本框),并在鼠标远离它时使其不可见。


我的问题是当我制作文本框消失,如果用户将焦点放在它上面并将鼠标移开,Access会给我一个当它有焦点时无法隐藏控件。错误。


我的问题是:我该如何解决这个问题?


后来我添加了这个: text2.SetFocus


我需要把注意力集中在别的东西上,但是我不能用当鼠标在表格的背景上移动时。事情,因为每当用户在背景上移动鼠标时,焦点将被设置为相同的东西,即用户键入text1(显示/隐藏文本框),然后想要更改text3(可见),但可以'不要移动鼠标,因为焦点会设置为text2。


这是我使用的代码:

展开 | 选择 | Wrap | 行号


如果我需要隐藏的文本框部分堆叠怎么办?这些盒子要么覆盖不必要的,要么显示超过必要的。


我可能会遗漏一些东西,因为我不知道你对''形式背景'的意思
但是假设你有一个复选框(chkControlName)并在表单上说两个文本框(txtName1和txtName2)。当鼠标移动到复选框时,它将显示txtName1。在失去对txtName1的关注之后,它将setfocus设置为txtName2并再次隐藏txtName。


在chkControlName的MouseMove事件中

展开 | 选择 | Wrap | 行号

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

解决方案

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


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.


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


这篇关于VBA - 显示/隐藏文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆