Ms access Access 97从VB创建对象
在access 97中,是否可以使用VB向表单中添加一些元素,例如标题为“Hello Word”、高度为300、宽度为700的命令按钮?尝试以下操作:Ms access Access 97从VB创建对象,ms-access,Ms Access,在access 97中,是否可以使用VB向表单中添加一些元素,例如标题为“Hello Word”、高度为300、宽度为700的命令按钮?尝试以下操作: Function AddCommandButtonFunction() Dim btn As CommandButton DoCmd.OpenForm "TestForm", acDesign On Error Resume Next DeleteControl "TestForm", "NewButton" On Error GoTo l
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
请注意,只有在设计模式下才允许添加/删除控件(以编程方式),是的,当然可以。你真正的问题是什么?您尝试过哪些内容,哪些不适合您?根据您尝试完成的内容,只需创建一个隐藏按钮,然后在运行时使用VBA显示/隐藏它可能会更容易。Me.CommandButton.Visible=True