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

Get Property Value from String ('Object Required' Error)

Status
Not open for further replies.

Rock6431

Programmer
Mar 23, 2002
56
US
I'm trying to return a Property Value in a function where the Property's name is supplied via another function that originates outside of the existing Project and this can be a random item, so setting it or calling it from outside the project will not work...

Here's what I've somewhat been tooling with

When I pass the value of "CustNAME" which is one of the properties in the existing project that was previously loaded with a value of let's say "Mike" I need to be able to request via a string and return the property value of "Mike".


Below are two of my attempts....

Private Function GetPropValue(strPropName) As String
On Error GoTo ErrorHandler

Dim ThisProj As ProjRampIT
Dim varProp As Property

Set ThisProj = CurrentProjRampit '=Current Obj
For Each varProp In ThisProj
If varProp.Name = strPropName Then
GetPropValue = varProp.Value
Exit Function
End If
Next
' If here then Property Requested is Invalid
GetPropValue = "ERR"

ExitHandler:

Exit Function

ErrorHandler:

DoEvents
TEST5 = Err.Description
Resume ExitHandler

End Function

-----------------OR------------------------------

Private Function GetPropValue(strPropName) As String
On Error GoTo ErrorHandler

Dim varProp As Property

For Each varProp In Properties
If varProp.Name = strPropName Then
GetPropValue = varProp.Value
Exit Function
End If
Next
' If here then Property Requested is Invalid
GetPropValue = "ERR"

ExitHandler:

Exit Function

ErrorHandler:

DoEvents
TEST5 = Err.Description
Resume ExitHandler

End Function

I continue to get returned the error message "Object Required.." well the object is the existing instance of
itself that I am inquiring into...?

Thanks in Advance for your help, Mike... :)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top