title: Access VBA Code not setting a variable to queried value
body: <p>I am kinda new to VBA, been working with it for 2 months but I'm stuck now. I have an access code that I use to calculate total hours for a project from a table with records of hours. My code successfully calculates hours for 3 categories but not the last two. I pull values from a query that sums up hours by project and save it to a variable, then update my project records with the correct values.</p>
  
  <p>Update: for the 4th check I used select to see if it would work better that way instead of using an IF statement, it was originally an if statement.</p>
  
  <p>Any help is greatly appreciated.</p>
  
  <p>my code is as follows:</p>
  
  <pre><code>Dim First As Integer
  Dim Second As Integer
  Dim Third As Integer
  Dim Fourth As Integer
  Dim Fifth As Integer
  Set db = CurrentDb
  
  Set rs = db.OpenRecordset("qryHermosaPCHoursSum1st", dbOpenDynaset, dbSeeChanges)
      rs.FindNext "PlanCheck Like " _
      &amp; Chr(34) &amp; "*" &amp; Me.PlanCheck &amp; "*" &amp; Chr(34)
  
      If rs.NoMatch Then
              First = 0
          Else
              First = (rs![SumOfHours])
      End If
  
  Set rs = db.OpenRecordset("qryHermosaPCHoursSum2nd", dbOpenDynaset, dbSeeChanges)
      rs.FindNext "PlanCheck Like " _
      &amp; Chr(34) &amp; "*" &amp; Me.PlanCheck &amp; "*" &amp; Chr(34)
  
      If rs.NoMatch Then
              Second = 0
          Else
              Second = (rs![SumOfHours])
      End If
  
  Set rs = db.OpenRecordset("qryHermosaPCHoursSum3rd", dbOpenDynaset, dbSeeChanges)
      rs.FindNext "PlanCheck Like " _
      &amp; Chr(34) &amp; "*" &amp; Me.PlanCheck &amp; "*" &amp; Chr(34)
  
      If rs.NoMatch Then
              Third = 0
          Else
              Third = (rs![SumOfHours])
      End If
  </code></pre>
  
  <p>Up to here it works fine.</p>
  
  <pre><code>Set rs = db.OpenRecordset("qryHermosaPCHoursSum4th", dbOpenDynaset, dbSeeChanges)
      rs.FindNext "PlanCheck Like " _
      &amp; Chr(34) &amp; "*" &amp; Me.PlanCheck &amp; "*" &amp; Chr(34)
  
      Select Case True
          Case rs.NoMatch
              Fourth = 0
          Case Else
              Fourth = (rs![SumOfHours])
      End Select
  </code></pre>
  
  <p>When I run the code line by line it seems to correctly grab the value of rs![SumOfHours] but fails to pass the value to Fourth and Fifth. I have a test record that has 15 matching hours that the query correctly sums but the code leaves it as zero.</p>
  
  <pre><code>Set rs = db.OpenRecordset("qryHermosaPCHoursSum5th", dbOpenDynaset, dbSeeChanges)
      rs.FindNext "PlanCheck Like " _
      &amp; Chr(34) &amp; "*" &amp; Me.PlanCheck &amp; "*" &amp; Chr(34)
  
      If rs.NoMatch Then
              Fifth = 0
          Else
              Fifth = (rs![SumOfHours])
      End If
  
  Set rs = db.OpenRecordset("tblHermosaBeachPC", dbOpenDynaset, dbSeeChanges)
      rs.FindNext "ID Like " _
      &amp; Chr(34) &amp; "*" &amp; Me.PlanCheck &amp; "*" &amp; Chr(34)
      rs.Edit
          rs![1stSetHours] = First
          rs![2ndSetHours] = Second
          rs![3rdSetHours] = Third
          rs![4thSetHours] = Fourth
          rs![5thSetHours] = Fifth
      rs.Update
  </code></pre>