none
Recordset.AbsolutePosition RRS feed

  • Pergunta

  • Eu tenho esta linha de código em programa, no "Current":

      Me!NumRegIntNova = "Registro " & CStr(Recordset.AbsolutePosition + 1) & " de " & CStr(Recordset.RecordCount)

    Ela conta os registros e os anota no rodapé do formulário.

    Quando eu apago um registro, ela dá erro, por causa da Recordset.AbsolutePosition.

    O código abaixo resolve o problema:

    If Recordset.AbsolutePosition = -1 Then
        DoCmd.GoToRecord , , acPrevious
     End If
     Me!NumRegIntNova = "Registro " & CStr(Recordset.AbsolutePosition + 1) & " de " & CStr(Recordset.RecordCount)

    Fiz a mesma coisa em outro programa e não funcionou, o VBA não reconhece a Recordset.AbsolutePosition = -1.

    Os dois programas podem ter origem em versões diferentes, mas agora estão, ambos, rodando em versão 2016.

    Alguma explicação?

    Sávio

    sexta-feira, 15 de fevereiro de 2019 14:51

Todas as Respostas

  • SSSANTOS,

       Talvez tenha uma diferença entre DAO e ADO...

    ===============================================
    Recordset.AbsolutePosition property (DAO)

    https://docs.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/recordset-absoluteposition-property-dao
    ===============================================
    Propriedade AbsolutePosition (ADO)

    https://docs.microsoft.com/pt-br/sql/ado/reference/ado-api/absoluteposition-property-ado?view=sql-server-2017
    ===============================================

        Esse código verifica se existe suporte para "AbsolutePosition":

    Public Sub RecordsetSupport(rst As ADODB.Recordset)
    
    If rst.Supports(adAddNew) Then
      Debug.Print "Supports AddNew"
    Else
      Debug.Print "Doesn't support AddNew"
    End If
    
    If rst.Supports(adApproxPosition) Then
      Debug.Print "Supports AbsolutePosition"
    Else
      Debug.Print "Doesn't support AbsolutePosition"
    End If
    
    If rst.Supports(adBookmark) Then
      Debug.Print "Supports Bookmarks"
    Else
      Debug.Print "Doesn't support Bookmarks"
    End If
    
    If rst.Supports(adDelete) Then
      Debug.Print "Supports Delete"
    Else
      Debug.Print "Doesn't support Delete"
    End If
    
    If rst.Supports(adFind) Then
      Debug.Print "Supports Find"
    Else
      Debug.Print "Doesn't support Find"
    End If
    
    If rst.Supports(adHoldRecords) Then
      Debug.Print "Supports Move without Save"
    Else
      Debug.Print "Doesn't support Move without Save"
    End If
    
    If rst.Supports(adIndex) Then
      Debug.Print "Supports Index"
    Else
      Debug.Print "Doesn't support Index"
    End If
    
    If rst.Supports(adMovePrevious) Then
      Debug.Print "Supports MovePrevious"
    Else
      Debug.Print "Doesn't support MovePrevious"
    End If
    
    If rst.Supports(adResync) Then
      Debug.Print "Supports Resync"
    Else
      Debug.Print "Doesn't support Resync"
    End If
    
    If rst.Supports(adSeek) Then
      Debug.Print "Supports Seek"
    Else
      Debug.Print "Doesn't support Seek"
    End If
    
    If rst.Supports(adUpdate) Then
      Debug.Print "Supports Update"
    Else
      Debug.Print "Doesn't support Update"
    End If
    
    If rst.Supports(adUpdateBatch) Then
      Debug.Print "Supports UpdateBatch"
    Else
      Debug.Print "Doesn't support UpdateBatch"
    End If
    
    End Sub           

    ===============================================
    The Supports Method of an ADO Recordset Object
    ADezii

    https://bytes.com/topic/access/insights/723038-supports-method-ado-recordset-object
    ===============================================

        Veja também:

    ===============================================
    ADO AbsolutePage and AbsolutePosition Property

    https://www.w3schools.com/asp/prop_rs_absolute.asp
    ===============================================
    AbsolutePosition and CursorLocation Properties Example (VB)

    https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/absoluteposition-and-cursorlocation-properties-example-vb?view=sql-server-2017
    ===============================================

    []'s,
    Fabio I.
    sábado, 16 de fevereiro de 2019 13:19