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
> Ribbon Onaction Event, Access 2016    
 
   
puttputt
post Jun 20 2019, 04:33 PM
Post#1



Posts: 11
Joined: 6-April 19



I'm attempting to implement the firing of a Ribbon onAction events on a Form rather than as a callback (re: UtterAccess.com/forum/lofiversion/index.php/t2045638.html). I've successfully implemented Albert Kallal's examples for launching a form and a report from a Ribbon that triggers a standard module function; however, I cannot get the onAction event to fire a Public Function from a Forms Module.

From the example provided: the onAction="=MyDelete" button will launch the standard module function but does not recognize the Form Module function by the same name.

It seems to me that the Form containing procedure being referenced is not active and therefore the Form level function cannot be found.

I appreciate any insight to what I may not be doing correctly.
Go to the top of the page
 
pere_de_chipstic...
post Jun 21 2019, 01:54 AM
Post#2


UtterAccess Editor
Posts: 10,509
Joined: 8-November 07
From: South coast, England


Hi puttputt

If I understand your post, you are trying to call a ribbon callback from a form.

This isn't possible as ribbon callbacks always require a reference to the calling ribbon which your form won't be able to provide.

If you create a new public sub or function with the code needed, both the ribbon callback and the form code will be able to call this sub/function.

HTH

--------------------
Warm regards
Bernie
Go to the top of the page
 
theDBguy
post Jun 21 2019, 07:19 AM
Post#3


Access Wiki and Forums Moderator
Posts: 76,425
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Welcome to UtterAccess!
welcome2UA.gif

Try using different function names. Just a thought...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
puttputt
post Jun 22 2019, 12:38 AM
Post#4



Posts: 11
Joined: 6-April 19



No luck with changing name. Still perplexed trying to get the public function on the Form Module to respond to the Ribbon onAction command. Have reloaded Kallal's example and can't seem to get it to fire the form's public procedure.


Go to the top of the page
 
theDBguy
post Jun 22 2019, 10:14 AM
Post#5


Access Wiki and Forums Moderator
Posts: 76,425
Joined: 19-June 07
From: SunnySandyEggo


How about creating a function to call it? Then call that function from the ribbon.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
puttputt
post Jun 22 2019, 12:16 PM
Post#6



Posts: 11
Joined: 6-April 19



Thank you for the response DBguy.
The public function (MyDelete) in the standard module has always worked so I attempted to call the form module (MyUserDelete) from there as follows:

Public Function MyDelete()
Call MyUserDelete
MsgBox "Hello from Standard Module"
End Function

Public Function MyUserDelete()
MsgBox "Hello from Forms Code Module"
End Function

MyUserDelete is not defined when I try to compile.

Am I missing something in trying to define a public function in the form module?



Go to the top of the page
 
theDBguy
post Jun 22 2019, 12:58 PM
Post#7


Access Wiki and Forums Moderator
Posts: 76,425
Joined: 19-June 07
From: SunnySandyEggo


To make sure I answer your question correctly, can you please post a sample demo copy of your db? Thanks.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
puttputt
post Jun 22 2019, 03:51 PM
Post#8



Posts: 11
Joined: 6-April 19



DBguy,

See attached culled down version of database illustrating problem as requested.

My interpretation of the ribbon example referenced earlier is that a public form level procedure, if it exists, will fire prior to a standard level procedure by the same name. The attached is my feeble (unsuccessful) attempt to duplicate the process in my database. Press the Run Function button to see msgbox results that standard level procedure is being fired.

PuttPutt
Attached File(s)
Attached File  RibbonFail.zip ( 49.06K )Number of downloads: 11
 
Go to the top of the page
 
puttputt
post Jun 24 2019, 11:02 PM
Post#9



Posts: 11
Joined: 6-April 19



Any feedback / direction on solving ribbon problem will be greatly appreciated.
Go to the top of the page
 
pere_de_chipstic...
post Jun 25 2019, 01:32 AM
Post#10


UtterAccess Editor
Posts: 10,509
Joined: 8-November 07
From: South coast, England


Hi puttputt

If I have wanted to call public code on a form from a ribbon, I've always used (e.g.) Forms!frmUserList.MyDelete.

The form must be open before it can be called: you could try:
CODE
Public Function MyDelete()
    If Application.CurrentProject.AllForms("frmUserList").IsLoaded Then
         Forms!frmUserList.MyDelete
    Else
        MsgBox "Hello from Standard Module"
    End If
End Function


hth

PS:

I did try using Albert's code at some time in the past but was not successful - for the same reason as you, but if you have functions with the same name on different forms you could use:

CODE
Public Function MyDelete()
Dim strForm as String
  strForm = Application.CurrentObjectName
    If Application.CurrentProject.AllForms(strForm).IsLoaded Then
         Forms(strForm ).MyDelete
    Else
        MsgBox "Hello from Standard Module"
    End If
End Function


If the 'MyDelete' function is always available from the current form then you could perhaps dispense with the is loaded check :
CODE
Public Function MyDelete()
   Forms(Application.CurrentObjectName).MyDelete
End Function


--------------------
Warm regards
Bernie
Go to the top of the page
 
puttputt
post Jun 25 2019, 11:25 AM
Post#11



Posts: 11
Joined: 6-April 19



Thank you for the response. I'll give it a try.
Go to the top of the page
 
pere_de_chipstic...
post Jul 1 2019, 11:12 AM
Post#12


UtterAccess Editor
Posts: 10,509
Joined: 8-November 07
From: South coast, England


Hi puttputt

Looking through this again I believe that you may only need to change your XML to call a function on the (current) form

from:
onAction="=MyDelete"
to:
onAction="=MyDelete()"

hth

--------------------
Warm regards
Bernie
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    23rd October 2019 - 12:27 AM