我想在Access窗体中创建200个带有for
循环的文本框,并将它们称为s1,s2,s3等。
我不想在表单设计中自己创建它们。我可以有一个代码示例吗?
答案 0 :(得分:5)
我同意这不是一个非常好的主意,但是为了给人们足够的绳索让自己挂起..........
Public Function Make_controls(iLoops As Integer)
DoCmd.OpenForm "frmYour_form", acDesign
Dim x As Integer
Dim ctrl As Control
For x = 1 To iLoops
Set ctrl = CreateControl("frmYour_form ", acTextBox, acDetail, , "", 0 + (x * 300), 0, 300, 240)
ctrl.ControlName = "txtDynamic_control_" & x
DoCmd.Save acForm, " frmYour_form "
Next x
DoCmd.Close acForm, " frmYour_form ", acSaveYes
End Function