T
Thomas V
Hi.
I've run into a VBA issue I can't seem to resolve.
I'm trying to use the 'GetField' method against a resource object but
for various reasons I can't provide the FieldID as a pjField type
variable. I do however have a string variable (strPjFieldName) which
has the FieldID name I need.
Is there a way to typecast from a String variable to a pjField
variable?
Here's some example code
Sub MySub()
Dim rs As Resources
Dim r As Resource
Dim strPjFieldName As String
Dim strMsg As String
strPjFieldName = "pjResourceBookingType"
Set rs = ActiveProject.Resources
For Each r In rs
If Not r Is Nothing Then
strMsg = strMsg & r.GetField(FieldID:=strPjFieldName) &
vbCr
End If
Next r
MsgBox strMsg
End Sub
What I would like is for this procedure to return the values of
"r.BookingType".
How does the example apply to a real scenario? Imagine you have a form
with 70 fields. Each of those representing a different field from the
resource object. I do not want to code the link between each form
field and its respective data field in the resource object
individually. Rather, I'd like to loop through all the fields on the
form, derive the resource field I need to source the data from, and
then get the data so I can display it on the form.
Thanks for your help.
Thomas Vanparys
I've run into a VBA issue I can't seem to resolve.
I'm trying to use the 'GetField' method against a resource object but
for various reasons I can't provide the FieldID as a pjField type
variable. I do however have a string variable (strPjFieldName) which
has the FieldID name I need.
Is there a way to typecast from a String variable to a pjField
variable?
Here's some example code
Sub MySub()
Dim rs As Resources
Dim r As Resource
Dim strPjFieldName As String
Dim strMsg As String
strPjFieldName = "pjResourceBookingType"
Set rs = ActiveProject.Resources
For Each r In rs
If Not r Is Nothing Then
strMsg = strMsg & r.GetField(FieldID:=strPjFieldName) &
vbCr
End If
Next r
MsgBox strMsg
End Sub
What I would like is for this procedure to return the values of
"r.BookingType".
How does the example apply to a real scenario? Imagine you have a form
with 70 fields. Each of those representing a different field from the
resource object. I do not want to code the link between each form
field and its respective data field in the resource object
individually. Rather, I'd like to loop through all the fields on the
form, derive the resource field I need to source the data from, and
then get the data so I can display it on the form.
Thanks for your help.
Thomas Vanparys