on action commandbars

  • Thread starter Thread starter Toxalot
  • Start date Start date
T

Toxalot

When customizing a toolbar and adding custom buttons, there is an on
action box. I understand that I can type a name of a VBA function
there. But I was wondering why it's a combo box. Is there a way to get
my VBA functions listed there, so I can just select from the list?

Jennifer
 
I would say that 90% of my custom menu bars call, and run my VBA code.

All you need to do is make the code (a function) public, and then simply
place the function name in the buttons on-action event code.

Further, likely often you will have specific code to a particular form, and
once again, you simply declare those functions (in that form) as public.

The syntax to call the code then is:

=YourFunctionName()

Also, if the code you write is for the particular form, then as mentioned,
you can simply place the code into the forms module code.

There is not a "drop down" list as you ask.....

Often, (if not most of the time), if going to place the code in a "standard"
code modle for use by MORE THEN one form, then your code you call will need
to pick up
some information about the current screen etc. So, my code most of the time
starts out, and grabs the current screen name. I use:

Public Function AskInvoicePrint()

Dim tblgroupid As Long
Dim frmActive As Form

Set frmActive = Screen.ActiveForm

tblgroupid = frmActive.frmMainClientB.Form!ID

If frmActive.InvoiceNumber = 0 Then
frmActive.InvoiceNumber = nextinvoice
frmActive.Refresh
End If

DoCmd.OpenForm "guiInvoicePrint", , , "id = " & tblgroupid

End Function

The above is code that the invoice print button runs. note how I right away
pick up the active form. After that, I can easily ref the forms object as if
the code was running much like the code would if put behind a button on the
form. In the above example, I also check if a invoice xnumber has been
generated before printing. And, the Refresh forces a disk write if in fact I
do change the invoice number. And, in addition the above clip also passes
the currently selected sub-form item that the invoice print form needs.
 
The "drop down" that I was referring to is in the propeties of the
menu item when you are customizing the menu. I discovered that the
drop down is populated automatically with macros, but I will just
stick to manually typing in the function name rather than creating a
whole bunch of macros.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top