PC Review


Reply
Thread Tools Rate Thread

Callback problems with Ribbon

 
 
gthelin
Guest
Posts: n/a
 
      11th Mar 2009
I am trying to get callbacks to work with ribbon. Nothing I try seems to
work. I get the error message "Microsoft Office Access can't run the macro
or callback function 'onOpenForm'. I have added the Microsoft Office Objects
12.0 Library but it still does not work. I tried creating a small db and did
get it to work there. But in the db that I need it I just get the error
message.

Here is the XML:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="false"> <tabs>
<tab id="tabMyStuff" label="MyStuff">
<group id="grpForms" label="Forms">
<button id="cmdOrders" label="Orders" onAction="onOpenForm"
tag="Orders" size="large"/>
<button id="cmdVendors" label="Orders2"
onAction="Ribbons.onOpenForm" tag="Orders" size="large"/>
</group>
<group id="grpReports" label="Reports">
<button id="cmdReports" label="Quote"
onAction="Ribbon.OpenfrmInvoice" size="large"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>

Here is the call back function (it is in a module called Ribbons).

Public Sub onOpenForm(ctl As IRibbonControl)
DoCmd.OpenForm ctl.Tag
End Sub

I tried to ref the callback in XML with the module name ribbons and with out
it. Nothing seems to work. Any thoughts?


 
Reply With Quote
 
 
 
 
Albert D. Kallal
Guest
Posts: n/a
 
      11th Mar 2009
The "on action" command does not pass the ribbon object, but just runs any
standard vba "PUBLIC" function you have..

So you On Action should be:

<button id="cmdOrders" label="Orders" onAction="=onOpenForm()"


note the additon of the = and also the ()

(the ribbion is quite picky in this regards).

So, now in a standard public module (or the the current forms module if you
want)
you then go:

Public Function onOpenform

end function

Of couse in your example you trying to use the "tag", and you don't need to,
just pass the value as a string right from the buttion like:

eg:

<button id="cmdOrders" label="Orders" onAction="=onOpenForm('Orders')"

In the above, we are passing 'Orders' to our routine, so:

Now, we would modify our code to :

Public Function onOpenform(strForm as string)

docmd.OpenForm strForm

end function


So, don't bother with the tag idea, just pass whatever form to that function
as string like above.

You can also use the same idea for reports....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(E-Mail Removed)



 
Reply With Quote
 
gthelin
Guest
Posts: n/a
 
      13th Mar 2009
Thanks for the help. I tried the code but it did not work in my database. I
created a new database and it did work there. Can you think what there might
be in my database that is preventing it from working?

"Albert D. Kallal" wrote:

> The "on action" command does not pass the ribbon object, but just runs any
> standard vba "PUBLIC" function you have..
>
> So you On Action should be:
>
> <button id="cmdOrders" label="Orders" onAction="=onOpenForm()"
>
>
> note the additon of the = and also the ()
>
> (the ribbion is quite picky in this regards).
>
> So, now in a standard public module (or the the current forms module if you
> want)
> you then go:
>
> Public Function onOpenform
>
> end function
>
> Of couse in your example you trying to use the "tag", and you don't need to,
> just pass the value as a string right from the buttion like:
>
> eg:
>
> <button id="cmdOrders" label="Orders" onAction="=onOpenForm('Orders')"
>
> In the above, we are passing 'Orders' to our routine, so:
>
> Now, we would modify our code to :
>
> Public Function onOpenform(strForm as string)
>
> docmd.OpenForm strForm
>
> end function
>
>
> So, don't bother with the tag idea, just pass whatever form to that function
> as string like above.
>
> You can also use the same idea for reports....
>
> --
> Albert D. Kallal (Access MVP)
> Edmonton, Alberta Canada
> (E-Mail Removed)
>
>
>
>

 
Reply With Quote
 
Albert D. Kallal
Guest
Posts: n/a
 
      14th Mar 2009
"gthelin" <(E-Mail Removed)> wrote in message
news:5E33F616-E3C8-4473-B498-(E-Mail Removed)...
> Thanks for the help. I tried the code but it did not work in my database.
> I
> created a new database and it did work there. Can you think what there
> might
> be in my database that is preventing it from working?


Well, I assume you done a debug-compile.

and other VBA code runs just fine in the application?

I suppose you could create a blank new database and then import everything
from the old one.

There has to be something really silly here that is not allowing the code to
work.

Note that the code called needs to be a FUNCTION, and MUST be public.
That public function the onAction calls can either be in the forms code
module, or a standard code module.

Do remember that each change you make to the ribbon requires you to exit,
and re-enter the application

(because of this, I put the compact and repair button on the "qat" (quick
access tool bar).

Now, when I change the ribbon...I just whack the compact/repair button
(think of that compact/repair button as a ribbon "compile" button....saves
you the time
having to exit and then re-enter the application.

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(E-Mail Removed)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
callback a gallery in xml ribbon khoick245 Microsoft Outlook Program Addins 0 10th Apr 2010 05:09 PM
Ribbon callback from built-in buttons to trigger additional code Andrew Microsoft Excel Programming 0 8th Feb 2010 01:41 PM
Excel ribbon XML callback with parameter HelpMeNow Windows XP 1 1st Nov 2009 01:57 PM
Callback For Ribbon Tab Click or Activate Jerry Fox Microsoft Access VBA Modules 1 4th Jun 2009 04:53 PM
Ribbon callback error RTY Microsoft Access VBA Modules 1 26th Feb 2009 05:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:12 PM.