Formularios, eventos, registros y operaciones

Formulario: Abrir con registro nuevo:

Private Sub Form_Open(Cancel As Integer)
    DoCmd.GoToRecord , , acNewRec
End Sub

Registros: Buscar el último registro relacionado a un id. DLast()

Private Sub id_producto_AfterUpdate()
    saldoanterior = DLast("[saldofinal]", "BodegaPrincipal", "BodegaPrincipal.[id_producto] = " & id_producto)
End Sub

Operaciones: Validar un retiro cuando hay saldo/existencia

Private Sub Retiro_AfterUpdate()
    If existencias < retiro Then
        retiro = 0
    End If
    saldofinal = saldoanterior - retiro
End Sub

Evento: Ejecutar consulta con click en botón

Private Sub Bt_anexar_Click()
    If anexado = False Then
        Me.Refresh
        DoCmd.OpenQuery "c_anexaordenretiro2", , acReadOnly
        anexado = True
        Me.Refresh
    End If
End Sub