Hi,
i found this code and have substituted parameters to suit my own needs however the loop is not working. Only the first record in my recordset (which is a test recordset of only 3 records) is being updated.
also, for testing only, the edit or update being applied is trivial: Description = "WHITE RESIN". If i can get the loop to work I want to substitute higher functionality to the module.
Please help, I basically understand when i read through the code but It just wont work yet.
Private Sub Update_Click()
Dim dbs As DAO.Database
Dim rsQuery As DAO.Recordset
Set dbs = CurrentDb
Set rsQuery = dbs.OpenRecordset("qryRmResin", dbOpenDynaset)
'Check to see if the recordset actually contains rows
If Not (rsQuery.EOF And rsQuery.BOF) Then
rsQuery.MoveFirst 'Unnecessary in this case, but still a good habit
Do Until rsQuery.EOF = True
'Perform an edit
Description = "WHITE RESIN"
'Move to the next record. Don't ever forget to do this.
rsQuery.MoveNext
Loop
Else
MsgBox "There are no records in the recordset."
End If
MsgBox "Finished looping through records."
rsQuery.Close 'Close the recordset
Set rsQuery = Nothing 'Clean up
End Sub
Thanks,
BJF
i found this code and have substituted parameters to suit my own needs however the loop is not working. Only the first record in my recordset (which is a test recordset of only 3 records) is being updated.
also, for testing only, the edit or update being applied is trivial: Description = "WHITE RESIN". If i can get the loop to work I want to substitute higher functionality to the module.
Please help, I basically understand when i read through the code but It just wont work yet.
Private Sub Update_Click()
Dim dbs As DAO.Database
Dim rsQuery As DAO.Recordset
Set dbs = CurrentDb
Set rsQuery = dbs.OpenRecordset("qryRmResin", dbOpenDynaset)
'Check to see if the recordset actually contains rows
If Not (rsQuery.EOF And rsQuery.BOF) Then
rsQuery.MoveFirst 'Unnecessary in this case, but still a good habit
Do Until rsQuery.EOF = True
'Perform an edit
Description = "WHITE RESIN"
'Move to the next record. Don't ever forget to do this.
rsQuery.MoveNext
Loop
Else
MsgBox "There are no records in the recordset."
End If
MsgBox "Finished looping through records."
rsQuery.Close 'Close the recordset
Set rsQuery = Nothing 'Clean up
End Sub
Thanks,
BJF