JPaulo
Developer
- Local time
- Today, 16:02
- Joined
- Dec 21, 2009
- Messages
- 185
Hi all;
I want to update from the bottom up (descending), but this loop is doing from top to bottom, as reverse ?
I want to update from the bottom up (descending), but this loop is doing from top to bottom, as reverse ?
Code:
Private Sub PreçoUnitário_Exit(Cancel As Integer)
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
On Error Resume Next
Dim strUP As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim i As Integer
Set rst = CurrentDb.OpenRecordset("Select * from DetalhesDoPedido Where NúmeroDoPedido=" & Me.NúmeroDoPedido)
strUP = Nz(DMax("[PreçoUnitário]", "DetalhesDoPedido", "[NúmeroDoPedido]=" & Me.NúmeroDoPedido & ""), 0)
Do While Not rst.EOF
If rst![CódigoDaCategoria] = 1 Then
rst.Edit
rst![Preço_Praticado] = strUP
rst.Update
ElseIf rst![CódigoDaCategoria] = 8 Then
Exit Do
End If
rst.MoveNext
Loop
rst.Close
On Error Resume Next
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToControl "NúmeroDoPedido"
End Sub