Connecting Tech Pros Worldwide Help | Site Map

Using OnAction

Ken
Guest
 
Posts: n/a
#1: Jan 24 '06
Please help I've been working on this for over a day.

The following code will run the GetComments function from a shortcut
menu.

.MoveFirst
Set cmb = Application.CommandBars.Add("Comments",
msoBarPopup, , True)
Do While Not .EOF
Set cbc = cmb.Controls.Add(msoControlButton)
cbc.Caption = strItem
cbc.Style = msoButtonCaption
cbc.OnAction = "GetComments"

.MoveNext
Loop


However when I try to pass a parameter to GetComments Using the
following line
cbc.OnAction = "GetComments(1)"
I get the Error message when the item is selected from the shortcut
menu.
Microsoft Access can't Run Macro of Call back Function 'GetComments(1)'


The code for the function is:
Sub GetComments(intComments As Integer)

MsgBox intComments

End Sub

Terry Kreft
Guest
 
Posts: n/a
#2: Jan 24 '06

re: Using OnAction



cbc.OnAction = "=GetComments(1)"


--

Terry Kreft


"Ken" <ken.sproat@police.vic.gov.au> wrote in message
news:1138071048.958664.24310@g43g2000cwa.googlegro ups.com...[color=blue]
> Please help I've been working on this for over a day.
>
> The following code will run the GetComments function from a shortcut
> menu.
>
> .MoveFirst
> Set cmb = Application.CommandBars.Add("Comments",
> msoBarPopup, , True)
> Do While Not .EOF
> Set cbc = cmb.Controls.Add(msoControlButton)
> cbc.Caption = strItem
> cbc.Style = msoButtonCaption
> cbc.OnAction = "GetComments"
>
> .MoveNext
> Loop
>
>
> However when I try to pass a parameter to GetComments Using the
> following line
> cbc.OnAction = "GetComments(1)"
> I get the Error message when the item is selected from the shortcut
> menu.
> Microsoft Access can't Run Macro of Call back Function 'GetComments(1)'
>
>
> The code for the function is:
> Sub GetComments(intComments As Integer)
>
> MsgBox intComments
>
> End Sub
>[/color]


Stephen Lebans
Guest
 
Posts: n/a
#3: Jan 26 '06

re: Using OnAction


I thought you couldn't pass parameters to functions in the OnAction property
of the Button? I'm sure I remember reading this in the Help file years ago.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Terry Kreft" <terry.kreft@mps.co.uk> wrote in message
news:fZadnXCF_-oF3kveSa8jmw@karoo.co.uk...[color=blue]
>
> cbc.OnAction = "=GetComments(1)"
>
>
> --
>
> Terry Kreft
>
>
> "Ken" <ken.sproat@police.vic.gov.au> wrote in message
> news:1138071048.958664.24310@g43g2000cwa.googlegro ups.com...[color=green]
>> Please help I've been working on this for over a day.
>>
>> The following code will run the GetComments function from a shortcut
>> menu.
>>
>> .MoveFirst
>> Set cmb = Application.CommandBars.Add("Comments",
>> msoBarPopup, , True)
>> Do While Not .EOF
>> Set cbc = cmb.Controls.Add(msoControlButton)
>> cbc.Caption = strItem
>> cbc.Style = msoButtonCaption
>> cbc.OnAction = "GetComments"
>>
>> .MoveNext
>> Loop
>>
>>
>> However when I try to pass a parameter to GetComments Using the
>> following line
>> cbc.OnAction = "GetComments(1)"
>> I get the Error message when the item is selected from the shortcut
>> menu.
>> Microsoft Access can't Run Macro of Call back Function 'GetComments(1)'
>>
>>
>> The code for the function is:
>> Sub GetComments(intComments As Integer)
>>
>> MsgBox intComments
>>
>> End Sub
>>[/color]
>
>[/color]


Lyle Fairfield
Guest
 
Posts: n/a
#4: Jan 26 '06

re: Using OnAction


Yes. When I put
=GetComments(1) in the UI dialog
the function is called and works

Terry Kreft
Guest
 
Posts: n/a
#5: Jan 26 '06

re: Using OnAction



I'm glad I forgot that (if I ever knew it <g>).

I tried it before posting and it worked, so I posted.


--

Terry Kreft


"Stephen Lebans" <ForEmailGotoMy.WebSite.-WWWdotlebansdot...@linvalid.com>
wrote in message news:KmUBf.1265$VV4.34745@ursa-nb00s0.nbnet.nb.ca...[color=blue]
> I thought you couldn't pass parameters to functions in the OnAction[/color]
property[color=blue]
> of the Button? I'm sure I remember reading this in the Help file years[/color]
ago.[color=blue]
>
> --
>
> HTH
> Stephen Lebans
> http://www.lebans.com
> Access Code, Tips and Tricks
> Please respond only to the newsgroups so everyone can benefit.
>
>
> "Terry Kreft" <terry.kreft@mps.co.uk> wrote in message
> news:fZadnXCF_-oF3kveSa8jmw@karoo.co.uk...[color=green]
> >
> > cbc.OnAction = "=GetComments(1)"
> >
> >
> > --
> >
> > Terry Kreft
> >
> >
> > "Ken" <ken.sproat@police.vic.gov.au> wrote in message
> > news:1138071048.958664.24310@g43g2000cwa.googlegro ups.com...[color=darkred]
> >> Please help I've been working on this for over a day.
> >>
> >> The following code will run the GetComments function from a shortcut
> >> menu.
> >>
> >> .MoveFirst
> >> Set cmb = Application.CommandBars.Add("Comments",
> >> msoBarPopup, , True)
> >> Do While Not .EOF
> >> Set cbc = cmb.Controls.Add(msoControlButton)
> >> cbc.Caption = strItem
> >> cbc.Style = msoButtonCaption
> >> cbc.OnAction = "GetComments"
> >>
> >> .MoveNext
> >> Loop
> >>
> >>
> >> However when I try to pass a parameter to GetComments Using the
> >> following line
> >> cbc.OnAction = "GetComments(1)"
> >> I get the Error message when the item is selected from the shortcut
> >> menu.
> >> Microsoft Access can't Run Macro of Call back Function 'GetComments(1)'
> >>
> >>
> >> The code for the function is:
> >> Sub GetComments(intComments As Integer)
> >>
> >> MsgBox intComments
> >>
> >> End Sub
> >>[/color]
> >
> >[/color]
>
>[/color]


Stephen Lebans
Guest
 
Posts: n/a
#6: Jan 26 '06

re: Using OnAction


One of the definate advantages to getting older.
;-)


Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Terry Kreft" <terry.kreft@mps.co.uk> wrote in message
news:iEKdncYXlsuMP0XeSa8jmw@karoo.co.uk...[color=blue]
>
> I'm glad I forgot that (if I ever knew it <g>).
>
> I tried it before posting and it worked, so I posted.
>
>
> --
>
> Terry Kreft
>
>
> "Stephen Lebans" <ForEmailGotoMy.WebSite.-WWWdotlebansdot...@linvalid.com>
> wrote in message news:KmUBf.1265$VV4.34745@ursa-nb00s0.nbnet.nb.ca...[color=green]
>> I thought you couldn't pass parameters to functions in the OnAction[/color]
> property[color=green]
>> of the Button? I'm sure I remember reading this in the Help file years[/color]
> ago.[color=green]
>>
>> --
>>
>> HTH
>> Stephen Lebans
>> http://www.lebans.com
>> Access Code, Tips and Tricks
>> Please respond only to the newsgroups so everyone can benefit.
>>
>>
>> "Terry Kreft" <terry.kreft@mps.co.uk> wrote in message
>> news:fZadnXCF_-oF3kveSa8jmw@karoo.co.uk...[color=darkred]
>> >
>> > cbc.OnAction = "=GetComments(1)"
>> >
>> >
>> > --
>> >
>> > Terry Kreft
>> >
>> >
>> > "Ken" <ken.sproat@police.vic.gov.au> wrote in message
>> > news:1138071048.958664.24310@g43g2000cwa.googlegro ups.com...
>> >> Please help I've been working on this for over a day.
>> >>
>> >> The following code will run the GetComments function from a shortcut
>> >> menu.
>> >>
>> >> .MoveFirst
>> >> Set cmb = Application.CommandBars.Add("Comments",
>> >> msoBarPopup, , True)
>> >> Do While Not .EOF
>> >> Set cbc = cmb.Controls.Add(msoControlButton)
>> >> cbc.Caption = strItem
>> >> cbc.Style = msoButtonCaption
>> >> cbc.OnAction = "GetComments"
>> >>
>> >> .MoveNext
>> >> Loop
>> >>
>> >>
>> >> However when I try to pass a parameter to GetComments Using the
>> >> following line
>> >> cbc.OnAction = "GetComments(1)"
>> >> I get the Error message when the item is selected from the shortcut
>> >> menu.
>> >> Microsoft Access can't Run Macro of Call back Function
>> >> 'GetComments(1)'
>> >>
>> >>
>> >> The code for the function is:
>> >> Sub GetComments(intComments As Integer)
>> >>
>> >> MsgBox intComments
>> >>
>> >> End Sub
>> >>
>> >
>> >[/color]
>>
>>[/color]
>
>[/color]


Terry Kreft
Guest
 
Posts: n/a
#7: Jan 26 '06

re: Using OnAction


Yes, the pause ..., before pronouncing your wise and considered opinions.
It's like ducks on a pond, underneath your brain is busily scrambling about
trying to remember what the question was, never mind deciding whether you
have a response <g>.

--

Terry Kreft


"Stephen Lebans" <ForEmailGotoMy.WebSite.-WWWdotlebansdot...@linvalid.com>
wrote in message news:6z5Cf.1600$VV4.43765@ursa-nb00s0.nbnet.nb.ca...[color=blue]
> One of the definate advantages to getting older.
> ;-)
>
>
> Stephen Lebans
> http://www.lebans.com
> Access Code, Tips and Tricks
> Please respond only to the newsgroups so everyone can benefit.
>
>
> "Terry Kreft" <terry.kreft@mps.co.uk> wrote in message
> news:iEKdncYXlsuMP0XeSa8jmw@karoo.co.uk...[color=green]
> >
> > I'm glad I forgot that (if I ever knew it <g>).
> >
> > I tried it before posting and it worked, so I posted.
> >
> >
> > --
> >
> > Terry Kreft
> >
> >
> > "Stephen Lebans"[/color][/color]
<ForEmailGotoMy.WebSite.-WWWdotlebansdot...@linvalid.com>[color=blue][color=green]
> > wrote in message news:KmUBf.1265$VV4.34745@ursa-nb00s0.nbnet.nb.ca...[color=darkred]
> >> I thought you couldn't pass parameters to functions in the OnAction[/color]
> > property[color=darkred]
> >> of the Button? I'm sure I remember reading this in the Help file years[/color]
> > ago.[color=darkred]
> >>
> >> --
> >>
> >> HTH
> >> Stephen Lebans
> >> http://www.lebans.com
> >> Access Code, Tips and Tricks
> >> Please respond only to the newsgroups so everyone can benefit.
> >>
> >>
> >> "Terry Kreft" <terry.kreft@mps.co.uk> wrote in message
> >> news:fZadnXCF_-oF3kveSa8jmw@karoo.co.uk...
> >> >
> >> > cbc.OnAction = "=GetComments(1)"
> >> >
> >> >
> >> > --
> >> >
> >> > Terry Kreft
> >> >
> >> >
> >> > "Ken" <ken.sproat@police.vic.gov.au> wrote in message
> >> > news:1138071048.958664.24310@g43g2000cwa.googlegro ups.com...
> >> >> Please help I've been working on this for over a day.
> >> >>
> >> >> The following code will run the GetComments function from a shortcut
> >> >> menu.
> >> >>
> >> >> .MoveFirst
> >> >> Set cmb = Application.CommandBars.Add("Comments",
> >> >> msoBarPopup, , True)
> >> >> Do While Not .EOF
> >> >> Set cbc = cmb.Controls.Add(msoControlButton)
> >> >> cbc.Caption = strItem
> >> >> cbc.Style = msoButtonCaption
> >> >> cbc.OnAction = "GetComments"
> >> >>
> >> >> .MoveNext
> >> >> Loop
> >> >>
> >> >>
> >> >> However when I try to pass a parameter to GetComments Using the
> >> >> following line
> >> >> cbc.OnAction = "GetComments(1)"
> >> >> I get the Error message when the item is selected from the shortcut
> >> >> menu.
> >> >> Microsoft Access can't Run Macro of Call back Function
> >> >> 'GetComments(1)'
> >> >>
> >> >>
> >> >> The code for the function is:
> >> >> Sub GetComments(intComments As Integer)
> >> >>
> >> >> MsgBox intComments
> >> >>
> >> >> End Sub
> >> >>
> >> >
> >> >
> >>
> >>[/color]
> >
> >[/color]
>
>[/color]


Closed Thread


Similar Microsoft Access / VBA bytes