Custom toolbar's code

G

Guest

Hi everyone

I am trying to troubleshoot a custom toolbar "mail to recipient as
attachment" button. This button works on reports and does not work like the
built in button that comes with access 2003. This custom toolbar is
distributed to individual workstations as part of an access project
application (sorry if I did not word that correctly). The name of the toolbar
is "afPreview". Can someone explain to me if I can and how to I view/debug
the code for this command button?

Thanks In Advance
kw
 
A

Albert D. Kallal

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()

Often, (if not most of the time), you code you call will need to pick up
some information about he 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 number 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.

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 no need
to pick up the active screen...and you can use me. as you
always used.

So, bring up the application, and right click the menu bar..choose cutomize.
IF the menu bar is not displayed, then display it (the toolbars tab...check
the check box for the menu bar). Then, ...you can then right click on the
menu bar, and view the on-action.

It is possible that the menu bar is a actually a built in one, and thus
there will not be any code written for the menu bar, but for my menu bars,
99% of them simply call my vba code...
 
G

Guest

Thanks, Albert

your explanation was right to the point, exactly what I was looking for and
very help in my future use of custom toolbars and command buttons. Thanks a
bunch!

kw
 

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

Top