By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,491 Members | 858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,491 IT Pros & Developers. It's quick & easy.

Using OnAction

P: n/a
Ken
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

Jan 24 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a

cbc.OnAction = "=GetComments(1)"
--

Terry Kreft
"Ken" <ke********@police.vic.gov.au> wrote in message
news:11*********************@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

Jan 24 '06 #2

P: n/a
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" <te*********@mps.co.uk> wrote in message
news:fZ********************@karoo.co.uk...

cbc.OnAction = "=GetComments(1)"
--

Terry Kreft
"Ken" <ke********@police.vic.gov.au> wrote in message
news:11*********************@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


Jan 26 '06 #3

P: n/a
Yes. When I put
=GetComments(1) in the UI dialog
the function is called and works

Jan 26 '06 #4

P: n/a

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:Km******************@ursa-nb00s0.nbnet.nb.ca...
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" <te*********@mps.co.uk> wrote in message
news:fZ********************@karoo.co.uk...

cbc.OnAction = "=GetComments(1)"
--

Terry Kreft
"Ken" <ke********@police.vic.gov.au> wrote in message
news:11*********************@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



Jan 26 '06 #5

P: n/a
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" <te*********@mps.co.uk> wrote in message
news:iE********************@karoo.co.uk...

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:Km******************@ursa-nb00s0.nbnet.nb.ca...
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" <te*********@mps.co.uk> wrote in message
news:fZ********************@karoo.co.uk...
>
> cbc.OnAction = "=GetComments(1)"
>
>
> --
>
> Terry Kreft
>
>
> "Ken" <ke********@police.vic.gov.au> wrote in message
> news:11*********************@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
>>
>
>



Jan 26 '06 #6

P: n/a
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:6z******************@ursa-nb00s0.nbnet.nb.ca...
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" <te*********@mps.co.uk> wrote in message
news:iE********************@karoo.co.uk...

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:Km******************@ursa-nb00s0.nbnet.nb.ca...
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" <te*********@mps.co.uk> wrote in message
news:fZ********************@karoo.co.uk...
>
> cbc.OnAction = "=GetComments(1)"
>
>
> --
>
> Terry Kreft
>
>
> "Ken" <ke********@police.vic.gov.au> wrote in message
> news:11*********************@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
>>
>
>



Jan 26 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.