如何使用Access VBA在textBox.Setfocus之后选择TextBox中的所有文本 [英] How to Select All Text in TextBox After textBox.Setfocus Using Access VBA

查看:363
本文介绍了如何使用Access VBA在textBox.Setfocus之后选择TextBox中的所有文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击(或双击)进入Access表单的文本框中时,需要选择所有文本。我尝试了以下代码,但未成功:

I need to select all the text in a textbox of an Access form when I click (or double click) into it. i tried the following code, unsuccessfully:

Me.txt_CompraPreco.SelStart = 0
Me.txt_CompraPreco.SelLength = Len(Me.txt_CompraPreco)

预先感谢。

推荐答案

您可以使用下面显示的代码。如果不起作用,请在代码的第一行放置一个断点。如果它没有在您的断点处停止,则您的事件将无法识别。

You can use the code shown below. If it doesn't work, place a breakpoint at the first line of code. If it doesn't stop on your breakpoint, then your event is not recognized.

Option Compare Database
Option Explicit

Private Sub txt_CompraPreco_Click()
    If Len(Me.txt_CompraPreco & "") = 0 Then Exit Sub
    Me.txt_CompraPreco.SelStart = 0
    Me.txt_CompraPreco.SelLength = Len(Me.txt_CompraPreco)
End Sub

这篇关于如何使用Access VBA在textBox.Setfocus之后选择TextBox中的所有文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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