VBA Access: Botón 'Ir a' un registro especificado
Tengo armado el código para que funcionen los botones Atrás, Anterior, Siguiente, Último y funcionan de maravillas (comparto el código más abajo). Por necesidad y unificar la estética del form, lo hago con botones. Y para mantener esa estética y necesidad, ahora necesito un campo donde ingresar un valor numérico y que al hacer clic en un botón "Ir a..." vaya a ese registro. ¿Es posible?
Busqué en varias Base de Datos de prueba que me pasaron y no encuentro esto.
Código de Botones:
' Botones de DESPLAZAMIENTO
Private Sub cmdDFirst_Click()
DoCmd.GoToRecord , , acFirst
Call CUENTAVERSIONES
MsgBox "Primer registro de la Consulta.", 64, "Desplazamiento"
End Sub
Private Sub cmdDAnt_Click()
On Error GoTo ERRH
Select Case x
Case Is <= Y
DoCmd.GoToRecord , , acPrevious
Case Else
MsgBox "Primer registro.", 48, "Desplazamiento"
End Select
Call CUENTAVERSIONES
ERRH:
If Err.Number = 0 Then
Exit Sub
ElseIf Err.Number = 2105 Then
MsgBox "Código: " & Err.Number & vbLf & Error$ & " Ya está en el primer registro.", 48, "Desplazamiento"
Exit Sub
Else
Mensajes.ERR_GENERAL_BY_N
End If
End Sub
Private Sub cmdDSig_Click()
On Error GoTo ERRH
Select Case x
Case Is <= Y
DoCmd.GoToRecord , , acNext
Case Else
MsgBox "Último registro.", 48, "Desplazamiento"
End Select
Call CUENTAVERSIONES
ERRH:
If Err.Number = 0 Then
Exit Sub
ElseIf Err.Number = 2105 Then
MsgBox "Código: " & Err.Number & vbLf & Error$ & " Ya está en el último registro.", 48, "Desplazamiento"
Exit Sub
Else
Mensajes.ERR_GENERAL_BY_N
End If
End Sub
Private Sub cmdDLast_Click()
DoCmd.GoToRecord , , acLast
Call CUENTAVERSIONES
MsgBox "Último registro de la Consulta.", 64, "Desplazamiento"
End Sub
Private Sub CuentaRegistros()
x = CurrentRecord
Y = DCount("*", "[VERSION]")
Call REGACT
End Sub
Private Sub REGACT()
Me.txtRecuento.Value = "Registro: " & x & " de " & Y & "."
End Sub
1 respuesta
Respuesta de Jacinto Trillo Jareño
2

