MarkK
bit cruncher
- Local time
- Today, 14:01
- Joined
- Mar 17, 2004
- Messages
- 8,437
OK, so to do the loop, I've amended your code a little. Most things are cosmetic but at the bottom you can see that we will print each name as we loop through each record in the recordset. This is our test of the loop, now that we have pretty good confidence in the SQL we've constructed . . .
So when we have confidence that is working, then we can do some more complex operation for each iteration of the loop.
Code:
Private Sub ExportClaimsBttn_Click()
Dim rs As DAO.Recordset
Dim sSQL As String
Dim iRecs As Integer
Dim dStart As Date
Dim dEnd As Date
Dim iSaudi As Integer
iSaudi = [Forms]![InvoiceOutputParameterDateForm]![NonSaudiProviderCkBx]
dStart = [Forms]![InvoiceOutputParameterDateForm]![StartDateTxtBx]
dEnd = [Forms]![InvoiceOutputParameterDateForm]![EndDateTxtBx]
sSQL = _
"SELECT DentalPracticeName " & _
"FROM Claims " & _
"WHERE DataEntryDate >= #" & dStart & "# " & _
"And DataEntryDate <= #" & dEnd & "# " & _
"And NonSaudiMbr = " & iSaudi & " " & _
"GROUP BY DentalPracticeName;"
Set rs = CurrentDb.OpenRecordset(sSQL, dbOpenDynaset, dbSeeChanges)
With rs
Do While Not .EOF [COLOR="Green"]'start loop[/COLOR]
Debug.Print .Fields(0) [COLOR="Green"]'print data from each record[/COLOR]
.MoveNext [COLOR="Green"]'move to the next record[/COLOR]
Loop
.Close
End With
End Sub