Q:

Looping through query in access

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 >= "0" And A_Char <= "9" Then
              Clean = Clean + A_Char
            End If
         Next Pos
         strCell = Clean
         strProv = DLookup("[EmailExt]", "CellProviders", "[CellProvider]='" & strProv & "'")
strTextEmail = strCell & strProv
End If

StrBCC = StrBCC & strTextEmail & ";"

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

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. 

A:

You are not reading the values from the recordset into your local variables. What you do right now, is reading the values from form controls (I guess). So these will not change if you move to the next record in the recordset.
Change the beginning of the loop like this:
With rst
  Do Until .EOF
    strCell = Nz(rst.Fields("CellPhone").Value, "0")
    strProv = Nz(rst.Fields("CellProvider").Value, "0")

