MS Access从模块更改文本框值

时间:2013-04-13 04:31:04

标签: variables ms-access vbscript textbox

我想根据模块中的输入框值更改报表中文本框的值。

Public Sub ChangeTextBox()
Dim UserText As String

UserText = InputBox("Enter The Value")
'The part I don't understand is how to branch out to the text box name
'I know you have to do something like Form!Formname.textbox name but I'm so confused
'How do I link it to the textbox from within module?

由于

1 个答案:

答案 0 :(得分:0)

尝试以下代码。

formname是表单名称 txtName是文本框名称

Public Sub ChangeTextBox()
    Dim UserText As String


    UserText = InputBox("Enter The Value")

    If UserText <> "" Then
        ActiveCell.Value = s
        formname.txtName = "dfd" ' where txtName is textbox name
    End If

End Sub

enter image description here

对象浏览器视图 enter image description here

enter image description here