title: In Microsoft Access 2010, how do I reference a bound control in a report?
body: <p>I am creating a report to display data on clients with several subreports to show different demographic data further broken by fiscal quarter. For example, my subreport on the primary language of the clients has a combobox control to create the rows in the detail section; the control is bound to my table of language choices(I'm not sure if this is relevant but I used an AutoNumber for the primary key of language choices instead of the name of the language itself as the key. I can change that though if needed). For the columns I created a label for each fiscal quarter.  What I'm trying to do is for each language choice in this bound control, I need it to see which clients speak that language, see when they were first served to break them down into the appropriate fiscal quarter, and display the count in the appropriate boxes.</p>
  
  <p>In other subreports like gender of new clients broken down by fiscal quarter it was easy. There's only M/F so there's no need to have it expandable so I just created the two rows with labels/rectangles and used some VBA to reference a query that gathered my client data. The query looks to see when they were first served and I wrote a function to return which Fiscal Quarter they belong to (Caution: amateur coding ahead =D  )</p>
  
  <pre><code>Public Function FiscalQuarter(InputDate As Date) As Integer
  
  Dim ReportMonth As Integer
  Dim ReportDay As Integer
  Dim ReportYear As Integer
  Dim FiscalYear As Integer
  
  
  '''!!! Break up Current Date !!!'''
  ReportMonth = Month(InputDate)
  ReportDay = Day(InputDate)
  ReportYear = Year(InputDate)
  
  ' Quarter 1
      If ReportMonth = "9" Then
          FiscalQuarter = 1
          FiscalYear = ReportYear + 1
      End If
      If ReportMonth = "10" Then
          FiscalQuarter = 1
          FiscalYear = ReportYear + 1
      End If
      If ReportMonth = "11" Then
          FiscalQuarter = 1
          FiscalYear = ReportYear + 1
      End If
  
  ' Quarter 2
      If ReportMonth = "12" Then
          FiscalQuarter = 2
          FiscalYear = ReportYear + 1
      End If
      If ReportMonth = "1" Then
          FiscalQuarter = 2
          FiscalYear = ReportYear
      End If
      If ReportMonth = "2" Then
          FiscalQuarter = 2
          FiscalYear = ReportYear
      End If
  
  ' Quarter 3
      If ReportMonth = "3" Then
          FiscalQuarter = 3
          FiscalYear = ReportYear
      End If
      If ReportMonth = "4" Then
          FiscalQuarter = 3
          FiscalYear = ReportYear
      End If
      If ReportMonth = "5" Then
          FiscalQuarter = 3
          FiscalYear = ReportYear
      End If
  
  ' Quarter 4
      If ReportMonth = "6" Then
          FiscalQuarter = 4
          FiscalYear = ReportYear
      End If
      If ReportMonth = "7" Then
          FiscalQuarter = 4
          FiscalYear = ReportYear
      End If
      If ReportMonth = "8" Then
          FiscalQuarter = 4
          FiscalYear = ReportYear
      End If
  
  End Function
  </code></pre>
  
  <p>Then in the ClientGender report I used code like the following:</p>
  
  <pre><code>MaleFirstQ = DCount("MinOfEventDate", "qryQRChildDemographics", "FiscalQuarter([MinOfEventDate])=1 And [Gender]='M'")
  MaleFirst.Caption = MaleFirstQ
  </code></pre>
  
  <p>For each gender/quarter box I have a snip of code resembling the above to assign to the caption.</p>
  
  <p>So my problem is that I am having trouble referencing the values in the bound control on the report to use in my Fiscal Quarter breakdown. I tried to use a Dcount similar to the one I already used except I was trying to use a reference to the bound control as a criteria and I kept getting different runtime errors saying that I made a reference to a control or property that doesn't exist.</p>
  
  <p>I'll admit that I'm somewhat of a novice and I enjoy figuring things out on my own by playing around with it, but I am completely stuck. I have been slowly poring through the Microsoft Access 2010 Bible, Microsoft Access 2010 In-Depth, and the Wrox Microsoft Access 2010 Programmer's Reference(Just started this one) books but so far I haven't found what I think I need. I have a feeling that my approach to this task is completely wrong so if anyone could point me in the right direction as far as what I'm overlooking and what tools to use I would greatly appreciate it! </p>
  
  <hr>
  
  <p>I tried several different ways, but they are all similar to this with slight changes in the second criteria:</p>
  
  <pre><code>LanguageFirst.Caption = DCount("PrimaryLanguage", "qryQRChildDemographics", "FiscalQuarter([MinOfEventDate])=1 AND Me!LanguageField")
  </code></pre>
  
  <p>Produces Run-time error 2471
  It doesn't like the Me!LanguageField.</p>
  
  <p>I've also tried this as the second criteria:</p>
  
  <pre><code>[PrimaryLanguage]=Me.Controls!LanguageField
  </code></pre>
  
  <p>I figured since I can use a function as a criteria that I should be able to use the value of a field too, but I'm starting to think that Dcount might not even be the right thing to use here.  </p>