title: Looping through query in access
body: <pre><code>Dim strCell As String
  Dim strProv As String
  Dim strTextEmail As String
  Dim oApp As Outlook.Application
  Dim oMail As MailItem
  Set oApp = CreateObject("Outlook.application")
  
  
  Dim StrBCC As String
  Dim rst As DAO.Recordset
  Dim qdf As DAO.QueryDef
  Dim db As DAO.Database
  
  Set db = CurrentDb
  Set qdf = db.QueryDefs("Staff Query")
  
  Set rst = qdf.OpenRecordset()
  
  With rst
  Do Until .EOF
  
  strCell = Nz([CellPhone], "0")
  strProv = Nz([CellProvider], "0")
  MsgBox [CellPhone]
  MsgBox [CellProvider]
  
  If strCell = "0" Or strProv = "0" Then
      MsgBox "MISSING DATA: Please double check the agent name, cell phone number and provider are entered in the staff table."
  Else
           Dim Clean As String
           Dim Pos, A_Char
           Pos = 1
           For Pos = 1 To Len(strCell)
              A_Char = Mid(strCell, Pos, 1)
              If A_Char &gt;= "0" And A_Char &lt;= "9" Then
                Clean = Clean + A_Char
              End If
           Next Pos
           strCell = Clean
           strProv = DLookup("[EmailExt]", "CellProviders", "[CellProvider]='" &amp; strProv &amp; "'")
  strTextEmail = strCell &amp; strProv
  End If
  
  
  StrBCC = StrBCC &amp; strTextEmail &amp; ";"
  
  rst.MoveNext
  Loop
  
  End With
  StrBCC = Left(StrBCC, Len(StrBCC) - 1)
  
  Set oMail = oApp.CreateItem(olMailItem)
  oMail.BCC = StrBCC
  oMail.Display
  
  Set oMail = Nothing
  Set oApp = Nothing
  Set rst = Nothing
  </code></pre>
  
  <p>I am trying to loop through the query "Staff Query" to send a text to everyone in it. I have everything working except the fact that it wont loop through the query, it loops through the first record on the form I open it on and it wont move. 
  Anyone have any suggestions for this? 
  Thank you in advance. </p>