ms-accessvbams-access-reports

How to incrementally number report details and set 0 if no records, Access Reports


I have an Access report with details (see image below). I have incremental numbering for the report details. I achieved this by creating a TextBox and setting it's Control Source: '=1' and Running Sum: 'Over Group'. This works well, but if I have no records the number shows up as 1 (I want this number to show up as 0). If I try to check if detail is NULL in VBA, it returns false if I have at least one Detail record in the entire report.

enter image description here

enter image description here


Solution

  • (Try 3)

    OK, so the red section does show up on a left join, because the query is returning Null for the missing records.

    So, your real fix is to:

    1. Select a detail field that that is always non-Null (I'll assume it is called ID)
    2. Set the control source of your counter control to:

      =IIf(IsNull([ID]),0,1)
      

    That way the running sum will show zero for emply detail groups.