ProjectUser said:
I've created a form that comprises mostly of text boxes. I need most of
these text boxes to show count values when the form is open/loaded. for
example, one text box needs to display the count value of all tasks with
"yes" in one of my customized fields.
Taking my given example, can someone help me with basic code needed to get
the results I'm looking for?
Thanks,
ProjectUser,
First of all, your code must count the number of instances for each item
represented by a text box. Depending on what you are counting, this data
may be available directly using the Count property. In your example,
that could mean applying a filter (via code) and then selecting all
tasks similar to the following
EditFIlter.....
FilterApply....
SelectTaskColumn
TheValue=ActiveSelection.Tasks.Count
Another method would be to loop through all tasks in the file and do a
running count of each desired parameter.
Once the values are obtained, they can be loaded into the userform text
boxes using the Initialize sub. For example, here is a code snippet from
a userform that is used in conjunction with a macro I created that is
used to escalate pay rates. The first part sets up the drop-down list
for the rate table and at the end I initialize the value of a text box
that holds the year. In your case, the values you gather from the above
code could be loaded via parameter transfer in the call to the userform,
or the above data gathering code could be part of the initialize code
itself.
Private Sub UserForm_initialize()
Dim UnoRTab As String, DosRTab As String, TraRTab As String
Dim QuaRTab As String, CinRTab As String
UnoRTab = "A" 'Default
DosRTab = "B"
TraRTab = "C"
QuaRTab = "D"
CinRTab = "E"
'set up selections for rate table option
CBoxRTable.List = Array(UnoRTab, DosRTab, TraRTab, QuaRTab, CinRTab)
CBoxRTable.ListIndex = 0
'set up default starting year
BaseYear = 2004
TxtBxFrom.Value = BaseYear
End Sub