在访问97中,是否可以使用VB向表单添加一些元素,比如一些命令按钮,其标题是“Hello Word”,哪个高度为300,宽度为700?
答案 0 :(得分:0)
尝试以下方法:
Function AddCommandButtonFunction()
Dim btn As CommandButton
DoCmd.OpenForm "TestForm", acDesign
On Error Resume Next
DeleteControl "TestForm", "NewButton"
On Error GoTo lberr
Set btn = CreateControl("TestForm", acCommandButton)
btn.Name = "NewButton"
btn.Caption = "Hello World!"
btn.Top = 500 'twips. 1 twip = 1/1440 in
btn.Left = 500 'twips
btn.Width = 2000 'twips
btn.Height = 500 'twips
DoCmd.Close acForm, "TestForm", acSaveYes
DoCmd.OpenForm "TestForm", acNormal
Exit Function
lberr:
MsgBox Err.Description
End Function
请注意在设计模式中允许添加/删除控件(以编程方式)