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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return the value of a control when the control is bound to a function

Status
Not open for further replies.

mike777

Programmer
Jun 3, 2000
387
US
I'm trying
Code:
Sub mike()
Dim A As Report
Dim b As Control
Dim c As Controls
Set A = Reports!rptCriteriaDesc
Set c = Reports!rptCriteriaDesc.Controls
For Each b In c
    If b.formula Like "Your*" Then
        MsgBox b.formula
    End If
Next
End Sub
But it's, like, not working.
I'm getting
Object doesn't support this property or method.
Hey, I'm just glad it's not "Object required." I get that all the time.
That's kinda the way you do it in Excel, so I figured it'd work here. D'oh!!
If you can help, thanks!
 
"Formula" is not a property of the Control object. That's why you're getting the message. Also, "Like" is an SQL operator, not a VB operator. You can't use it in VB expressions, only in SQL statements.

You can use the Object Browser to discover the properties of objects like Control. First, you have to open a code window. Then, hit F2 to open the Object Browser.

What you probably want here is the Value property. To test just the left four characters in the string, you can do this:
Code:
   If Left$(b.Value, 4) = "Your" Then
Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top