Search code examples
vbams-project

Run-Time error '1004': The field "Active" Does Not Exist


I'm receiving this error on a user's PC. They are using Project 2013 on Windows 7. On our own test machines with Project 2013 on Windows 10 and Project 2016 on Windows 10), we are not seeing the same error.

The error's getting thrown all over the place, but one example is FilterEdit found here here:

Sub STAT_Leads_Preds()
    FilterEdit Name:="STAT_Leads_Preds", TaskFilter:=True, Create:=True, OverwriteExisting:=True, FieldName:="Predecessors", Test:="contains", Value:="-", ShowInMenu:=False, ShowSummaryTasks:=False
    FilterEdit Name:="STAT_Leads_Preds", TaskFilter:=True, FieldName:="", NewFieldName:="Actual Finish", Test:="equals", Value:="NA", Operation:="And", ShowSummaryTasks:=False
    If Not pActive Then
        FilterEdit Name:="STAT_Leads_Preds", TaskFilter:=True, FieldName:="", NewFieldName:="Active", Test:="equals", Value:="Yes", Operation:="And", ShowSummaryTasks:=False
    Else
    End If
End Sub

It's unclear why this message appears. "Active" is, in fact, a field. And, like I said, we are not seeing this issue on test machines.

For reference, here's what the error looks like: enter image description here


Solution

  • Looks like Project Standard does not have the "Active" field. Our solution involved checking for the edition of the software using Application.Edition, which can be one of two values: pjEditionProfessional or pjEditionStandard.

    Here's how the code ended up looking:

    Sub STAT_Leads_Preds()
        FilterEdit Name:="STAT_Leads_Preds", TaskFilter:=True, Create:=True, OverwriteExisting:=True, FieldName:="Predecessors", Test:="contains", Value:="-", ShowInMenu:=False, ShowSummaryTasks:=False
        FilterEdit Name:="STAT_Leads_Preds", TaskFilter:=True, FieldName:="", NewFieldName:="Actual Finish", Test:="equals", Value:="NA", Operation:="And", ShowSummaryTasks:=False
        If Not pActive And Application.Edition = pjEditionProfessional Then
            FilterEdit Name:="STAT_Leads_Preds", TaskFilter:=True, FieldName:="", NewFieldName:="Active", Test:="equals", Value:="Yes", Operation:="And", ShowSummaryTasks:=False
        Else
        End If
    End Sub