开发者

Access 97 creating object from VB

In access 97, is it 开发者_StackOverflow中文版possible to add some element to the form using VB, like some command button whose caption is "Hello Word" and which height is 300 and width 700?


Try the following:

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

Please note adding/deleting of control (programmatically) is only allowed in Design mode

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜