title: VBA Access Code Review Request
body: <p>I would like to get a general code review on the following code.
  This code is part of an automated decision making process to determine which entires need to be added to a table in the database. I would just like to have another pair of eyes to check for Syntax errors and and general logic flaws.</p>
  
  <pre><code>Private Sub btnAddEnt_Click()
  Dim strEnt As String
  Dim Direct As Integer
  Dim Indirect As Integer
  Dim DirectNum As Currency
  Dim IndirectNum As Currency
  Dim db As Database
  Set db = CurrentDb
  Dim disRs As DAO.Recordset
  Dim dayRs As DAO.Recordset
  Dim Jan As Currency
  Dim Feb As Currency
  Dim Mar As Currency
  Dim Apr As Currency
  Dim May As Currency
  Dim Jun As Currency
  Dim Jul As Currency
  Dim Aug As Currency
  Dim Sep As Currency
  Dim Oct As Currency
  Dim Nov As Currency
  Dim Dec As Currency
  Dim DKClient As String
  Dim DKNum As Integer
  strEnt = "INSERT INTO EntList (EntityID, BusinessUnit, EntityName, Position, Location, Client, Dept, DistKey, Salary, Currency, SQ&amp;A, BillRate, Util%, MeritDate, MeritRate) " &amp; _
           "VALUES ('" &amp; Me.EntityID &amp; "', '" &amp; Me.BusinessUnit &amp; "', '" &amp; Me.EntityName &amp; "', '" &amp; Me.Position &amp; "', '" &amp; Me.Location &amp; "', '" &amp; Me.Client &amp; "', '" &amp; Me.Dept &amp; "', '" &amp; Me.DistKey &amp; "', '" &amp; Me.Salary &amp; "', '" &amp; Me.Currency &amp; "', '" &amp; Me.SG_A &amp; "', '" &amp; Me.BillRate &amp; "', '" &amp; Me.Util_ &amp; "', '" &amp; Me.MeritDate &amp; "', '" &amp; Me.Merit_ &amp; "');"
  DoCmd.RunSQL strEnt
  Direct = (1 - Me.SG_A)
  Indirect = Me.SG_A
  If Direct &gt; 0 Then
      DirectNum = Direct * Me.Salary / 12
  End If
  If Indirect &gt; 0 Then
      IndirectNum = Indirect * Me.Salary / 12
  End If
  If Me.BillRate &gt; 0 Then
      Set dayRs = db.OpenRecordset("SELECT WrkDays FROM WrkDays ORDER BY WrkMonth;")
      dayRs.MoveFirst
      Set DayNum = dayRs.Fields("WrkDays")
      While Not dayRs.EOF
          Jan = (Me.BillRate * DayNum) * Me.Util_
          dayRs.MoveNext
          Feb = (Me.BillRate * DayNum) * Me.Util_
          dayRs.MoveNext
          Mar = (Me.BillRate * DayNum) * Me.Util_
          dayRs.MoveNext
          Apr = (Me.BillRate * DayNum) * Me.Util_
          dayRs.MoveNext
          May = (Me.BillRate * DayNum) * Me.Util_
          dayRs.MoveNext
          Jun = (Me.BillRate * DayNum) * Me.Util_
          dayRs.MoveNext
          Jul = (Me.BillRate * DayNum) * Me.Util_
          dayRs.MoveNext
          Aug = (Me.BillRate * DayNum) * Me.Util_
          dayRs.MoveNext
          Sep = (Me.BillRate * DayNum) * Me.Util_
          dayRs.MoveNext
          Oct = (Me.BillRate * DayNum) * Me.Util_
          dayRs.MoveNext
          Nov = (Me.BillRate * DayNum) * Me.Util_
          dayRs.MoveNext
          Dec = (Me.BillRate * DayNum) * Me.Util_
      Wend
  End If
  If Me.DistKey &lt;&gt; "N/A" Then
      Set disRs = db.OpenRecordset("SELECT Client, DistPer FROM DistMap WHERE DistKey = '" &amp; Me.DistKey &amp; "';")
      disRs.MoveFirst
      Set DKClient = disRs.Fields("Client")
      Set DKNum = disRs.Fields("DistPer")
      While Not disRs.EOF
          If Direct &gt; 0 Then
              DoCmd.RunSQL ("INSERT INTO ForcastTrans (Location, Client, Department, Account, EntityID, Description, Currency, Month1, Month2, Month3, Month4, Month5, Month6, Month7, Month8, Month9, Month10, Month11, Month12) " &amp; _
                            "VALUES ('" &amp; Me.Location &amp; "', DKClient, '" &amp; Me.Dept &amp; "', '5010 SALARIES/WAGES - ADMIN', '" &amp; Me.EntityID &amp; "', 'Payroll', '" &amp; Me.Currency &amp; "', DirectNum * DKNum, DirectNum * DKNum, DirectNum * DKNum, DirectNum * DKNum, DirectNum * DKNum, DirectNum * DKNum, DirectNum * DKNum, DirectNum * DKNum, DirectNum * DKNum, DirectNum * DKNum, DirectNum * DKNum, DirectNum * DKNum);")
          End If
          If Indirect &gt; 0 Then
              DoCmd.RunSQL ("INSERT INTO ForcastTrans (Location, Client, Department, Account, EntityID, Description, Currency, Month1, Month2, Month3, Month4, Month5, Month6, Month7, Month8, Month9, Month10, Month11, Month12) " &amp; _
                            "VALUES ('" &amp; Me.Location &amp; "', DKClient, '" &amp; Me.Dept &amp; "', '7010 SALARIES/WAGES - ADMIN', '" &amp; Me.EntityID &amp; "', 'Payroll', '" &amp; Me.Currency &amp; "', IndirectNum*DKNum, IndirectNum * DKNum, IndirectNum * DKNum, IndirectNum * DKNum, IndirectNum * DKNum, IndirectNum * DKNum, IndirectNum * DKNum, IndirectNum * DKNum, IndirectNum * DKNum, IndirectNum * DKNum, IndirectNum * DKNum, IndirectNum * DKNum);")
          End If
          If Me.BillRate &gt; 0 Then
              DoCmd.RunSQL ("INSERT INTO ForcastTrans (Location, Client, Department, Account, EntityID, Description, Currency, Month1, Month2, Month3, Month4, Month5, Month6, Month7, Month8, Month9, Month10, Month11, Month12) " &amp; _
                            "VALUES ('" &amp; Me.Location &amp; "', DKClient, '" &amp; Me.Dept &amp; "', '4900 CONSULTING FEES', '" &amp; Me.EntityID &amp; "', 'Revenue', '" &amp; Me.Currency &amp; "', Jan * DKNum, Feb * DKNum, Mar * DKNum, Apr * DKNum, May * DKNum, Jun * DKNum, Jul * DKNum, Aug * DKNum, Sep * DKNum, Oct * DKNum, Nov * DKNum, Dec * DKNum);")
          End If
          disRs.MoveNext
      Wend
  Else
      If Direct &gt; 0 Then
          DoCmd.RunSQL ("INSERT INTO ForcastTrans (Location, Client, Department, Account, EntityID, Description, Currency, Month1, Month2, Month3, Month4, Month5, Month6, Month7, Month8, Month9, Month10, Month11, Month12) " &amp; _
                        "VALUES ('" &amp; Me.Location &amp; "', '" &amp; Me.Client &amp; "', '" &amp; Me.Dept &amp; "', '5010 SALARIES/WAGES - ADMIN', '" &amp; Me.EntityID &amp; "', 'Payroll', '" &amp; Me.Currency &amp; "', DirectNum, DirectNum, DirectNum, DirectNum, DirectNum, DirectNum, DirectNum, DirectNum, DirectNum, DirectNum, DirectNum, DirectNum);")
      End If
      If Indirect &gt; 0 Then
          DoCmd.RunSQL ("INSERT INTO ForcastTrans (Location, Client, Department, Account, EntityID, Description, Currency, Month1, Month2, Month3, Month4, Month5, Month6, Month7, Month8, Month9, Month10, Month11, Month12) " &amp; _
                        "VALUES ('" &amp; Me.Location &amp; "', '" &amp; Me.Client &amp; "', '" &amp; Me.Dept &amp; "', '7010 SALARIES/WAGES - ADMIN', '" &amp; Me.EntityID &amp; "', 'Payroll', '" &amp; Me.Currency &amp; "', IndirectNum, IndirectNum, IndirectNum, IndirectNum, IndirectNum, IndirectNum, IndirectNum, IndirectNum, IndirectNum, IndirectNum, IndirectNum, IndirectNum);")
      End If
      If Me.BillRate &gt; 0 Then
          DoCmd.RunSQL ("INSERT INTO ForcastTrans (Location, Client, Department, Account, EntityID, Description, Currency, Month1, Month2, Month3, Month4, Month5, Month6, Month7, Month8, Month9, Month10, Month11, Month12) " &amp; _
                        "VALUES ('" &amp; Me.Location &amp; "', '" &amp; Me.Client &amp; "', '" &amp; Me.Dept &amp; "', '4900 CONSULTING FEES', '" &amp; Me.EntityID &amp; "', 'Revenue', '" &amp; Me.Currency &amp; "', Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec);")
      End If
  End If
  </code></pre>
  
  <p>End Sub</p>
  
  <p>I am getting an error on the following line of code
     Set DKClient = disRs.Fields("Client")
  it says Compile Error Object required But I have the object declared already.</p>