UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Custom Ribbon & Button - Run Code On Click, Access 2013    
 
   
David92595
post Jul 6 2017, 03:53 PM
Post#1



Posts: 522
Joined: 27-June 11
From: Temecula, California


I've reviewed other questions similar to this one and still can't find my answer. I'm sure it's something simple...

I have the following XML code to create a custom ribbon and button which calls a public function (below). However, when I click the button I get an errors stating: "Microsoft Access cannot run the macro or callback function 'Fix_Morty_Test'. make sure the macro or function exists and takes the correct parameters."



CODE
<?xml version="1.0" encoding="utf-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon startFromScratch="false">
    <tabs>
      <tab idMso="TabAddIns" visible="false"/>
      <tab id="Morty" label="MORTY">
        <group id="Fix_My_Morty" label="Fix My Morty">
           <button id="Fix_Morty" label="Fix Morty" imageMso="HappyFace"
               onAction="Fix_Morty_Test"
              size="large" supertip="Click to Fix Morty"/>
        </group>

      </tab>
     </tabs>
  </ribbon>
</customUI>


CODE
Public Function Fix_Morty_Test()
        Debug.Print "Hello World"
End Function


what am I doing wrong???

David92595
Go to the top of the page
 
theDBguy
post Jul 6 2017, 04:59 PM
Post#2


Access Wiki and Forums Moderator
Posts: 71,237
Joined: 19-June 07
From: SunnySandyEggo


Hi David,

Try changing your XML as follows:

...onAction="=Fix_Morty_Test"...

Notice the additional "=" symbol. You may or may not need to add the "()" as well.

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
David92595
post Jul 6 2017, 05:16 PM
Post#3



Posts: 522
Joined: 27-June 11
From: Temecula, California


I'm getting a slightly different error now. grin.gif


"Microsoft Access cannot find the name 'Fix_Morty_Test' you entered in the expression. You may have specified a control that wasn't on the current object without secifying the correct form or report context."
Go to the top of the page
 
theDBguy
post Jul 6 2017, 08:15 PM
Post#4


Access Wiki and Forums Moderator
Posts: 71,237
Joined: 19-June 07
From: SunnySandyEggo


Did you try it with the parens? Also, did you save your function in a Standard Module?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
David92595
post Jul 6 2017, 09:35 PM
Post#5



Posts: 522
Joined: 27-June 11
From: Temecula, California


second equal sign: Yes
parens: No
Standard module: yes

I've made the change, so I can answer yes to all 3, and now I'm getting the following error:
"There was an error compiling this function. The Visual Basic module contains a syntax error. Check the code, and then recompile it."

Here's my (current) problem. All I'm doing is printing "Hello World". There is nothing to debug. I've tried changing the function to a sub, as most the examples I've see are using, but I get the same error.

Is this error symptomatic of something else?

Thanks again,

David92595
Go to the top of the page
 
theDBguy
post Jul 6 2017, 09:48 PM
Post#6


Access Wiki and Forums Moderator
Posts: 71,237
Joined: 19-June 07
From: SunnySandyEggo


Hi David,

Try compiling your code to see if it compiles. If you get errors, you'll have to fix them first. To see an example of how to call public functions from the Ribbon, try downloading any one of my demos (from my website).

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
David92595
post Jul 7 2017, 02:51 PM
Post#7



Posts: 522
Joined: 27-June 11
From: Temecula, California


All of the examples I've seen are based on a form being opened which then loads the ribbon. I'm looking for the opposite, I'd like the ribbon to load automatically without a form opening. I'm hoping to use this to create a button that will pull a fresh copy of my front end if there is an issue during an automated version update. The particular circumstance I'm trying to solve is my default form either does not load or loads but has no coding behind it. This generally occurs if there was a network issue of some sort. I currently have a button available to pull a fresh copy on my default page, but it doesn't always work due to the reasosn mentioned.

Do any other solutions come to mind that may help solve this problem?

Thanks!
David92595
Go to the top of the page
 
theDBguy
post Jul 7 2017, 03:17 PM
Post#8


Access Wiki and Forums Moderator
Posts: 71,237
Joined: 19-June 07
From: SunnySandyEggo


Hi David,

I think all of my demos load the Ribbon without needing to open any form. Have you looked to see if it answers your question?

If you see a form opens automatically, it's only because a demo is not really good without a splash form. Just go to File > Options and select None for Display Form, then restart the db and see if the Ribbon still comes up.

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
David92595
post Jul 10 2017, 05:42 PM
Post#9



Posts: 522
Joined: 27-June 11
From: Temecula, California


I took a look at yours and you're correct. I think I botched the CallbackOnLoad coding, as simple as it is.

Thanks again!

David92595
Go to the top of the page
 
theDBguy
post Jul 16 2017, 10:18 AM
Post#10


Access Wiki and Forums Moderator
Posts: 71,237
Joined: 19-June 07
From: SunnySandyEggo


Hi David,

Glad to hear you got it sorted out. Good luck with your project.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    18th December 2017 - 11:45 AM