PDA

View Full Version : Solved: Help with Commad bar



JKwan
07-28-2011, 07:40 AM
I have the following:

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

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

Sub FindCaseNumber()
Dim SynergiCaseNumber As CommandBarControl
Set SynergiCaseNumber = CommandBars("ProcessSafetyTotals").FindControl(, , "FindSynergiCaseNumber")
MsgBox SynergiCaseNumber.Text
End Sub

I am always getting blank.... Is there a way that I can read the control's text?

Aflatoon
07-28-2011, 08:26 AM
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?

JKwan
07-28-2011, 08:32 AM
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