使用字符串作为属性名称

时间:2017-10-26 15:00:20

标签: vba ms-access access-vba

我正在尝试将值设置为文本框,方法是将它们称为字符串

文本框名称均遵循以下格式: 例如。 txt_N1txt_N2

我希望能够通过增加文本框名称的整数来查看文本框,这看起来像"txt_N" & CStr(intRow)

我不确定我是怎么做的。 以下是我到目前为止所做的事情

intRow = 1  'The 1st Row 
recVat.MoveFirst 'Go to the 1st record in the recordset

'Loop through the records
Do Until intRow = 4 Or recVat.EOF             

    'Set the text boxes in the VAT Summary
    strNet = "txt_N" & CStr(intRow)

    Me!strNet = recVat![SumOfnet_t]       


    'Move to the Next Record
    recVat.MoveNext
    intRow = intRow + 1

Loop

1 个答案:

答案 0 :(得分:3)

不要使用爆炸符号,而是使用常规符号,这应该很容易:

  Me.Controls(strNet).Value = recVat![SumOfnet_t]  
相关问题