El botón que dice PRIMERO se llamará cmdprimero
El botón que dice SIGUIENTE se llamará cmdsiguiente
El botón que dice ANTERIOR se llamará cmdanterior
El botón que dice ULTIMO se llamará cmdultimo
El botón que dice NUEVO se llamará cmdnuevo
El botón que dice EDITAR se llamará cmdeditar
El botón que dice ELIMINAR se llamará cmdeliminar
El botón que dice GUARDAR se llamará cmdguardar
El botón que dice SALIR se llamará cmdsalir
Ahora copia los siguientes códigos en la ventana de codigo:
Private Sub cmdanterior_Click()
Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
End If
End Sub
Private Sub cmdprimero_Click()
Adodc1.Recordset.MoveFirst
End Sub
Private Sub cmdsalir_Click()
End
End Sub
Private Sub cmdsiguiente_Click()
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
End If
End Sub
Private Sub cmdultimo_Click()
Adodc1.Recordset.MoveLast
End Sub
Private Sub cmdguardar_Click()
Adodc1.Recordset.Update
habilitarbotones
cmdguardar.Enabled = False
inhabilitarcajas
End Sub
Private Sub cmdnuevo_Click()
habilitarcajas
inhabilitarbotones
cmdguardar.Enabled = True
cmdcancelar.Enabled = True
Adodc1.Recordset.AddNew
txtnit.SetFocus
End Sub
Private Sub cmdanterior_Click()
Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
End If
End Sub
Private Sub cmdprimero_Click()
Adodc1.Recordset.MoveFirst
End Sub
Private Sub cmdsalir_Click()
End
End Sub
Private Sub cmdsiguiente_Click()
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
End If
End Sub
Private Sub cmdultimo_Click()
Adodc1.Recordset.MoveLast
End Sub
Private Sub cmdguardar_Click()
Adodc1.Recordset.Update
habilitarbotones
cmdguardar.Enabled = False
inhabilitarcajas
End Sub
Private Sub cmdnuevo_Click()
habilitarcajas
inhabilitarbotones
cmdguardar.Enabled = True
cmdcancelar.Enabled = True
Adodc1.Recordset.AddNew
txtnit.SetFocus
End Sub
Private Sub cmdeditar_Click()
habilitarcajas
inhabilitarbotones
cmdguardar.Enabled = True
cmdcancelar.Enabled = True
txtnit.SetFocus
End Sub
Private Sub cmdeliminar_Click()
Dim r As Integer
On Error GoTo RutinaDeError
r = MsgBox("¿Desea eliminar el registro?", vbYesNo, "Atención")
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
End If
Exit Sub
RutinaDeError:
r = MsgBox(Error, vbOKOnly, "Se ha producido un error: ")
Adodc1.Recordset.CancelUpdate
End Sub
Private Sub inhabilitarcajas()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is TextBox Then
Controls(n).Enabled = False
End If
Next n
End Sub
Private Sub habilitarcajas()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is TextBox Then
Controls(n).Enabled = True
End If
Next n
End Sub
Private Sub inhabilitarbotones()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is CommandButton Then
Controls(n).Enabled = False
End If
Next n
End Sub
Private Sub habilitarbotones()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is CommandButton Then
Controls(n).Enabled = True
End If
Next n
End Sub
habilitarcajas
inhabilitarbotones
cmdguardar.Enabled = True
cmdcancelar.Enabled = True
txtnit.SetFocus
End Sub
Private Sub cmdeliminar_Click()
Dim r As Integer
On Error GoTo RutinaDeError
r = MsgBox("¿Desea eliminar el registro?", vbYesNo, "Atención")
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
End If
Exit Sub
RutinaDeError:
r = MsgBox(Error, vbOKOnly, "Se ha producido un error: ")
Adodc1.Recordset.CancelUpdate
End Sub
Private Sub inhabilitarcajas()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is TextBox Then
Controls(n).Enabled = False
End If
Next n
End Sub
Private Sub habilitarcajas()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is TextBox Then
Controls(n).Enabled = True
End If
Next n
End Sub
Private Sub inhabilitarbotones()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is CommandButton Then
Controls(n).Enabled = False
End If
Next n
End Sub
Private Sub habilitarbotones()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is CommandButton Then
Controls(n).Enabled = True
End If
Next n
End Sub
Private Sub inhabilitarcombobox()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is combobox Then
Controls(n).Enabled = False
End If
Next n
End Sub
Private Sub habilitarcombobox()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is combobox Then
Controls(n).Enabled = True
End If
Next n
End Sub
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is combobox Then
Controls(n).Enabled = False
End If
Next n
End Sub
Private Sub habilitarcombobox()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is combobox Then
Controls(n).Enabled = True
End If
Next n
End Sub
Private Sub inhabilitardtpicker()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is DtPicker Then
Controls(n).Enabled = False
End If
Next n
End Sub
Private Sub habilitarDtPicker()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is DtPicker Then
Controls(n).Enabled = True
End If
Next n
End Sub
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is DtPicker Then
Controls(n).Enabled = False
End If
Next n
End Sub
Private Sub habilitarDtPicker()
Dim n As Integer
For n = 0 To Controls.Count - 1
If TypeOf Controls(n) Is DtPicker Then
Controls(n).Enabled = True
End If
Next n
End Sub
No hay comentarios:
Publicar un comentario
No dejes de comentar!!!