Ms access 如何制作用于for循环的变量
如何在VBA Access中将文本框放入for循环Ms access 如何制作用于for循环的变量,ms-access,vba,Ms Access,Vba,如何在VBA Access中将文本框放入for循环 txta1=a(1) txta2=a(2) txta3=a(3) 我们在FoxPro中: txta&i =a(i) 试试这个 for i=1 to n me.controls("txta" & i)=a(i) next i 欢迎来到stackoverflow。请阅读如何提问:谢谢,但我无法解决我的问题。此代码正在运行:子测试Dim a40作为整数a1=1 a2=2 a3=3 DoCmd.OpenForm FR_证书,acV
txta1=a(1)
txta2=a(2)
txta3=a(3)
我们在FoxPro中:
txta&i =a(i)
试试这个
for i=1 to n
me.controls("txta" & i)=a(i)
next i
欢迎来到stackoverflow。请阅读如何提问:谢谢,但我无法解决我的问题。此代码正在运行:子测试Dim a40作为整数a1=1 a2=2 a3=3 DoCmd.OpenForm FR_证书,acViewLayout With Forms![FR_Certificate].txta1.Value=a1.txta2.Value=a2.txta3.Value=a3以End Sub结尾,但当我更改时。txta1.Value=a1.txta2.Value=a2.txta3.Value=a3以For I=1到3 Me.Controls.txta&I.Value=ai下一次我遇到语法错误。非常感谢。如何使用变量I而不是数字1在C中编写textBox1.Text?您已将@h2so4的代码修改为毫无意义的代码。@ali,如果您想使用点的话。要引用.txt1、.txt2、.txt3,请使用以下语法。controlstxt&i=ai即删除指令中的me。Controlstxta&i.Value=ai有效。非常感谢你,h2so4。
Thank you but I couldn't solve my problem.This code is working:
Sub test()
Dim a(40) As Integer
a(1) = "1"
a(2) = "2"
a(3) = "3"
DoCmd.OpenForm "FR_Certificate", acViewLayout
With Forms![FR_Certificate]
.txta1.Value = a(1)
.txta2.Value = a(2)
.txta3.Value = a(3)
End With
End Sub
but when I change
.txta1.Value = a(1)
.txta2.Value = a(2)
.txta3.Value = a(3)
with
For i = 1 To 3
Me.Controls(."txta" & i.value) = a(i)
Next i
I got synntax error.