Esta es la respuesta más completa que te podemos aportar, pero primero estúdiala pausadamente y analiza si se puede adaptar a tu proyecto.
Ejemplo 1: bucle VBA a través del conjunto de registros
'The short version
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT * FROM Contacts")
If Not (rs.EOF And rs.BOF) Then
Do Until rs.EOF = True
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
Ejemplo 2: bucle vba a través del conjunto de registros
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT * FROM Contacts")
'Check to see if the recordset actually contains rows
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst 'Unnecessary in this case, but still a good habit
Do Until rs.EOF = True
'Perform an edit
rs.Edit
rs!VendorYN = True
rs("VendorYN") = True 'The other way to refer to a field
rs.Update
'Save contact name into a variable
sContactName = rs!FirstName & " " & rs!LastName
'Move to the next record. Don't ever forget to do this.
rs.MoveNext
Loop
Else
MsgBox "There are no records in the recordset."
End If
MsgBox "Finished looping through records."
rs.Close 'Close the recordset
Set rs = Nothing 'Clean up
Acuérdate de que te damos el privilegio decir si hallaste tu impedimento justo a tiempo.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)