Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old January 24th, 2006, 03:05 AM
Ken
Guest
 
Posts: n/a
Default Using OnAction

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

  #2  
Old January 24th, 2006, 03:25 PM
Terry Kreft
Guest
 
Posts: n/a
Default 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]


  #3  
Old January 26th, 2006, 12:15 AM
Stephen Lebans
Guest
 
Posts: n/a
Default 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]


  #4  
Old January 26th, 2006, 01:25 AM
Lyle Fairfield
Guest
 
Posts: n/a
Default Re: Using OnAction

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

  #5  
Old January 26th, 2006, 10:25 AM
Terry Kreft
Guest
 
Posts: n/a
Default 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]


  #6  
Old January 26th, 2006, 03:15 PM
Stephen Lebans
Guest
 
Posts: n/a
Default 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]


  #7  
Old January 26th, 2006, 03:45 PM
Terry Kreft
Guest
 
Posts: n/a
Default 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]


 

Bookmarks

Thread Tools

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles