Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Firing Proc with Argument from Command Button

Status
Not open for further replies.

idbr

MIS
May 1, 2003
247
GB
Hi,

Any ideas why this doesn't work?

Code:
        With cmd

             .Style = msoButtonIconAndCaption
             .Caption = "Collapse to Here"
             .FaceId = 188
             .OnAction = "'Collapse_To_Node""" & CStr(nd.Key) & """'"

         End With

The proc doesn't even fire on pressing the button (which is on a popup menu btw, not sure if this might have something to do with it).

The argument is passed to the button and the button properties show 'Collapse_To_Node "E123"' as the OnAction property.

If I remove the argument it works just fine.

nd is a selected treeview node, the node and key are both <> nothing and neither is the Key null.

Any suggestions gratefully received.

Thanks, Iain
 
1. What's the full procedure where this is located? It's got to be in the cmd_Click() event, best I can tell...

2. Have you tried stepping through the code? Use F8 or just insert a Break Point in the code, and THEN use F8 if need be...

3. This should happen really fast - so, depending upon your form, and depending upon your computer hardware where this is located, it could just be too fast for you to see it..

4. What do you mean it's on a pop-up menu... Please explain a little further - if it's a command button, then it's not in a menu.. if it's in a menu, it's a menu item..

--

"If to err is human, then I must be some kind of human!" -Me
 
Using chr(39) and chr(32) in place of quote punctuation helps me in preventing headaches and bugs.

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
Good point, GKC..

--

"If to err is human, then I must be some kind of human!" -Me
 
Anyway, I don't think you can use arguments in the OnAction property of a CommandBarButton.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi all,

kjv1611, I've tried adding breakpoints to my procedure, and stepping through, this is showing that the called procedure isn't firing at all.

Yes, it's a menu item, located on a custom shortcut menu, probably should have included this in the post:

Set cmdbar = Application.CommandBars.Add("TreeviewPopUp", msoBarPopup, False, True)

Set cmd = cmdbar.Controls.Add(msoControlButton)

The command bar is created dynamically, in response to a treeview mouse_down event. It works fine in terms of setting the property for the commandbar button. Just doesn't fire the proc as it should. Removing the argument makes the proc fire just fine.

GKChesterton,

Tried that, didn't help.

PHV,

Apparently you can?


Although this is an Excel implementation - maybe it doesn't transfer to Access?

Thanks all, Iain
 
There are some things which may work in Excel, but not Access, and vice-versa in VBA.

--

"If to err is human, then I must be some kind of human!" -Me
 
Could you please post the definition of the Collapse_To_Node procedure ?
Anyway I'd replace this:
.OnAction = "'Collapse_To_Node""" & CStr(nd.Key) & """'"
with this:
Code:
.OnAction = "'Collapse_To_Node[highlight] [/highlight]""" & nd.Key & """'"


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV,


I've done that, but it didn't work either.

Code as requested:

Code:
Public Function Collapse_To_Node(strKey As String)

Dim tvw As Control
Dim nd As node

Dim strCompareNode As String
Dim strCompareInput As String

' nodes are created so that each key holds the definition of all of its parents
' by comparing these, we can collapse only the nodes that are ultimate children ofthe selected node

strCompareInput = Right(strKey, Len(strKey) - 1)

On Error Resume Next

Set tvw = Forms!frmHomeManager.tvwHomes

For Each nd In tvw.Nodes

    strCompareNode = Left(nd.Key, Len(strKey))
    strCompareNode = Right(strCompareNode, Len(strCompareNode) - 1)
    
    If strCompareInput = strCompareNode Then
        
        nd.Expanded = False
        
    End If

Next nd

Set tvw = Nothing

End Function

Thanks, iain
 
NB: I've tried it as a Sub too, it just says function cos I tested if that would work!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top