Consulting

Results 1 to 3 of 3

Thread: Solved: Help with Commad bar

  1. #1
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location

    Solved: Help with Commad bar

    I have the following:
    [VBA]
    With cb.Controls.Add(Type:=msoControlButton)
    .BeginGroup = True
    .Caption = "Find Synergi case #"
    .TooltipText = "Find Synergi case # - Globally"
    .Style = msoButtonCaption
    .OnAction = "FindCaseNumber"
    End With

    With cb.Controls.Add(Type:=msoControlEdit)
    .Text = ""
    .Tag = "FindSynergiCaseNumber"
    .TooltipText = "Find Synergi case # - Globally"
    End With
    [/VBA]
    What I am trying to do is to read what was typed into the Control Edit object, however, I am failing miserably! I thought that I can read it by
    [VBA]
    Sub FindCaseNumber()
    Dim SynergiCaseNumber As CommandBarControl
    Set SynergiCaseNumber = CommandBars("ProcessSafetyTotals").FindControl(, , "FindSynergiCaseNumber")
    MsgBox SynergiCaseNumber.Text
    End Sub
    [/VBA]
    I am always getting blank.... Is there a way that I can read the control's text?

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Are you pressing enter after adding text to the edit box? If not, you will see that the contents get cleared when you click the other button. Is there a reason for not assigning the macro to the edit box itself?
    Be as you wish to seem

  3. #3
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    Thank you Aflatoon, once I pressed Enter, my control gets the assignment.
    Not assigning to the control....., well, I feel embarassed now, I never thought of it! I guess that I will assign it to the control so when the user press the Enter key, it will use it as the parameter.

    Thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •