MS Access 2003 - 通过单击标签框将简单值输入到文本框中

时间:2022-02-22 15:38:29

Ok so could anyone please help me out with the VB for auto entering information into a text box, by clicking certian label boxes on a form in access 2003.

好的,有人可以通过点击访问2003中表单上的certian标签框,帮助我通过VB自动将信息输入到文本框中。

I built this thing using label boxes as "sort of links" instead of button for navigation/commands etc, and I have this power point presentation viewer on one of the forms.
The client has numerous briefings and this will be great for me to provide a little something for them to be able to get their briefings from one spot.

我使用标签盒作为“链接”而不是导航/命令按钮等来构建这个东西,我在其中一个表单上有这个power point presentation viewer。客户有很多简报,这对我来说很有意义,可以让他们从一个地方获得简报。

So if I list the choices for the month out on the form as label boxes (with little mouse move events to resemble a web link) and they click on it to select, then the only way I know how this may become functional is if I add a text box to the form, and make it not visible, that way I can name it, and add it to the file path string and it works.

因此,如果我在表单上列出月份的选项作为标签框(小鼠标移动事件类似于Web链接)并点击它选择,那么我知道这可能变得功能的唯一方法是,如果我在表单中添加一个文本框,并使其不可见,这样我就可以将其命名,并将其添加到文件路径字符串中并且它可以正常工作。

But how do I create the action of clicking the "link" result in "NVOWEFDJHF" into text box?

但是如何在“文本框”中创建单击“NVOWEFDJHF”中“链接”结果的操作?

Anyone know a better way?
Yeah I am an amateur, so I am ALWAYS willing to learn a better way.

谁知道更好的方法?是的我是业余爱好者,所以我总是愿意学习更好的方法。

Thanks very much!

非常感谢!

3 个解决方案

#1


I would recommend using a transparent button instead of a label.

我建议使用透明按钮而不是标签。

The main reason is that you can set the mouse cursor to become a small hand when you hover over the button, so it gives back information to the user that this can be clicked.
With a label, the user cannot make the difference between a normal label and one that can be clicked since there is no visual cue.

主要原因是当您将鼠标悬停在按钮上时,可以将鼠标光标设置为小手,因此它会向用户返回可以单击此信息的信息。使用标签,用户无法区分普通标签和可以点击的标签,因为没有视觉提示。

To create a button that resemble a label:

要创建类似标签的按钮:

  • Add the button to the form
  • 将按钮添加到表单

  • In the properties for the button, set the following:
    • Format > Back-Style: Transparent
    • 格式>背面风格:透明

    • Other > Cursor on Hover: Hyperlink Hand
    • 其他>悬停上的光标:超链接手

    • Other > Name: btAutoFill (or whatever name you want)
    • 其他>名称:btAutoFill(或任何你想要的名字)

  • 在按钮的属性中,设置以下内容:格式>后退样式:透明其他>悬停上的光标:超链接手其他>名称:btAutoFill(或任何您想要的名称)

  • If you want the button to resemble a link a bit more, you can change it's caption's format, making it blue and underlined if you wish.
  • 如果您希望按钮更像一个链接,您可以更改它的标题格式,如果您愿意,可以将其设置为蓝色和下划线。

Now if you view the form, you will see that the mouse cursor will change when you move over the 'button label'.

现在,如果您查看表单,您将看到当您移动“按钮标签”时鼠标光标将会改变。

To automatically fill-in other controls when you click your button, add the code to handle its OnClick event (in the button's properties, under Events > On Click, choose [Event Procedure]):

要在单击按钮时自动填充其他控件,请添加代码以处理其OnClick事件(在按钮的属性中,在“事件”>“单击”下,选择[事件过程]):

Public Sub btAutoFill_Click()
    myTextBox = "NVOWEFDJHF"
End Sub

#2


Quick air code here...

快速空气代码在这里......

Private Sub MyLabel_OnClick()

  Me.MyTextBox = "NVOWEGDJHF"

End Sub

Don't forget your error handling.

不要忘记你的错误处理。

#3


You're making this as difficult as possible by using an approach that is not Access-native. The simplest way to make the labels "clickable" is to put a transparent command button over them. But that means the MouseMove events will go to the command button, so you'll have to have its events do the MouseOver actions.

通过使用非本地访问方法,您将尽可能地使其变得困难。使标签“可点击”的最简单方法是在它们上面放置一个透明的命令按钮。但这意味着MouseMove事件将转到命令按钮,因此您必须让其事件执行MouseOver操作。

#1


I would recommend using a transparent button instead of a label.

我建议使用透明按钮而不是标签。

The main reason is that you can set the mouse cursor to become a small hand when you hover over the button, so it gives back information to the user that this can be clicked.
With a label, the user cannot make the difference between a normal label and one that can be clicked since there is no visual cue.

主要原因是当您将鼠标悬停在按钮上时,可以将鼠标光标设置为小手,因此它会向用户返回可以单击此信息的信息。使用标签,用户无法区分普通标签和可以点击的标签,因为没有视觉提示。

To create a button that resemble a label:

要创建类似标签的按钮:

  • Add the button to the form
  • 将按钮添加到表单

  • In the properties for the button, set the following:
    • Format > Back-Style: Transparent
    • 格式>背面风格:透明

    • Other > Cursor on Hover: Hyperlink Hand
    • 其他>悬停上的光标:超链接手

    • Other > Name: btAutoFill (or whatever name you want)
    • 其他>名称:btAutoFill(或任何你想要的名字)

  • 在按钮的属性中,设置以下内容:格式>后退样式:透明其他>悬停上的光标:超链接手其他>名称:btAutoFill(或任何您想要的名称)

  • If you want the button to resemble a link a bit more, you can change it's caption's format, making it blue and underlined if you wish.
  • 如果您希望按钮更像一个链接,您可以更改它的标题格式,如果您愿意,可以将其设置为蓝色和下划线。

Now if you view the form, you will see that the mouse cursor will change when you move over the 'button label'.

现在,如果您查看表单,您将看到当您移动“按钮标签”时鼠标光标将会改变。

To automatically fill-in other controls when you click your button, add the code to handle its OnClick event (in the button's properties, under Events > On Click, choose [Event Procedure]):

要在单击按钮时自动填充其他控件,请添加代码以处理其OnClick事件(在按钮的属性中,在“事件”>“单击”下,选择[事件过程]):

Public Sub btAutoFill_Click()
    myTextBox = "NVOWEFDJHF"
End Sub

#2


Quick air code here...

快速空气代码在这里......

Private Sub MyLabel_OnClick()

  Me.MyTextBox = "NVOWEGDJHF"

End Sub

Don't forget your error handling.

不要忘记你的错误处理。

#3


You're making this as difficult as possible by using an approach that is not Access-native. The simplest way to make the labels "clickable" is to put a transparent command button over them. But that means the MouseMove events will go to the command button, so you'll have to have its events do the MouseOver actions.

通过使用非本地访问方法,您将尽可能地使其变得困难。使标签“可点击”的最简单方法是在它们上面放置一个透明的命令按钮。但这意味着MouseMove事件将转到命令按钮,因此您必须让其事件执行MouseOver操作。