Public Function NumeroDecimales(ByVal dNumber As Double) As Long
On Error GoTo error
Dim Value As String
Dim PosSymb As String
Dim DecSymb As String
Dim NumDecs As Long
DecSymb = Mid(1 / 2, 2, 1)
Value = CStr(dNumber)
PosSymb = InStr(Value, DecSymb)
If CLng(PosSymb) > 0 Then
NumDecs = Len(Value) - CLng(PosSymb)
Else
NumDecs = 0
End If
NumeroDecimales = NumDecs
Exit Function
error:
NumeroDecimales = 0
MsgBox Err.number & ": " & Err.Description
End Function
domingo, 25 de marzo de 2018
miércoles, 7 de marzo de 2018
VBA Access. Posicionar cursor en un registro concreto de un formulario con datos DAO.Recordset
Private Sub GotoRecord(ByVal strCriteria As String)
'Ejemplo stCriteria: [PKey] = 'ABCD'
On Error GoTo error
Dim rs As DAO.Recordset
Set rs = Me.SubForm.Form.RecordsetClone
rs.FindFirst strCriteria
If rs.NoMatch Then
'Ningún valor encontrado
Else
Me.Subform.Form.Bookmark = rs.Bookmark
End If
Exit Sub
error:
MsgBox Err.Description
End Sub
'Ejemplo stCriteria: [PKey] = 'ABCD'
On Error GoTo error
Dim rs As DAO.Recordset
Set rs = Me.SubForm.Form.RecordsetClone
rs.FindFirst strCriteria
If rs.NoMatch Then
'Ningún valor encontrado
Else
Me.Subform.Form.Bookmark = rs.Bookmark
End If
rs.Close
Set rs = Nothing
Exit Sub
error:
MsgBox Err.Description
End Sub
VBA Access. Posicionar cursor en un registro concreto de un formulario con datos ADODB.Recordset
Private Sub GotoRecord(ByVal strCriteria As String)
'Ejemplo stCriteria: [PKey] = 'ABCD'
Set rs = Me.SubForm.Form.RecordsetClone
rs.Filter = strCriteria
If Not rs.EOF Then
Me.SubForm.Form.Bookmark = rs.Bookmark
End If
rs.Close
Set rs = Nothing
Exit Sub
error:
MsgBox Err.Description
End Sub
'Ejemplo stCriteria: [PKey] = 'ABCD'
On Error GoTo error
Dim rs As ADODB.RecordsetSet rs = Me.SubForm.Form.RecordsetClone
rs.Filter = strCriteria
If Not rs.EOF Then
Me.SubForm.Form.Bookmark = rs.Bookmark
End If
rs.Close
Set rs = Nothing
Exit Sub
error:
MsgBox Err.Description
End Sub
martes, 6 de marzo de 2018
VBA Access. Finalizar la edición de un registro que se está modificando en un formulario.
'Finaliza edicion registro
If Me.Dirty Then
Me.Dirty = False
End If
If Me.Dirty Then
Me.Dirty = False
End If
Suscribirse a:
Entradas (Atom)
VBA Access. Redondeo de números decimales con el método medio redondeo. Alternativa a la función Round (bankers round)
Private Function Redondeo(ByVal Numero As Variant, ByVal Decimales As Integer) As Double 'Aplica método medio redondeo (half round ...
-
Option Compare Database Option Explicit '***************************** ' 'Ejemplo de uso ' 'selecciona 1 ficher...
-
Option Compare Database Option Explicit 'Zip / UnZip file or folder 'http://www.codekabinett.com/rdumps.php?Lang=2&targetDoc...