Share via

OnAction Method For CommandBar Button Does Not Work

Anonymous
2019-02-28T09:58:53+00:00

Hi 

I Have Created ShortMnu1 And Use In Button Click Event ( Created Successfully ) But OnAction Method Just When Created Will Be Worked 

Another Question How Can Add Seperator Between Control Buttons 

Dim Mnu

Dim CbarBtn1

If Commandbars("ShortMnu1").Name="ShortMnu1" Then   Commandbars("ShortMnu1").Delete

Set Mnu=Commandbars.Add("ShortMnu1",msoBarPopup,,True)

Set CbarBtn1=mnu.Controls.Add msoControlButton 

CbarBtn1.Caption="Report1"

CbarBtn1.OnAction="=MyFunc()"

Have I Mention Form ' s reference ? Like 

.OnAction=MyFunc("Forms!Form1") 

Or

.OnAction="MyFunc(Form1)"

And For Seperator Using  CbarBtn1.Controls(1).BeginGroup=True?

��������������

Function MyFunc()

Docmd.OpenReport "Report1",acViewPreview

End Function

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2019-03-03T09:07:54+00:00

    Answer Found : 

    CbarBtn1.OnAction="=MyFunc()"  ' This Is True

    Copy Bellow CallBack Function In Standard Madoule Only And It Does Work 

    Function MyFunc()

    Docmd.OpenReport "Report1",acViewPreview

    End Function 

    Mnu.Controls(1).BeginGroup=True '  Sperate Button in New Group

    Was this answer helpful?

    0 comments No comments