ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Visual Basic


Enviado por   •  26 de Abril de 2015  •  2.934 Palabras (12 Páginas)  •  173 Visitas

Página 1 de 12

PASOS PARA ENLAZAR ACCESS CON VISUAL BASIC 6.0

1.- Botón secundario sobre el cuadro de herramientas elegir componentes.

2.- En la ventana que aparece seleccionar “Microsoft ADO Data control 6.0 (OLEDB). Presionar Aceptar.

3.- En el cuadro de herramientas aparecera el icono siguiente colocarlo en el formulario.

4.- seleccionar el ADODC1 y modificar las siguientes propiedades:

CONECCIONSTRING:

PRESIONAR ACEPTAR

RECORDSOURCE: Seleccionar Tipo de Comando “2-adcmdTable”, en tabla o nombre de procedimiento almacenado “Elige tu tabla de Access”. Y presiona Aceptar.

5.- En cada caja de texto modifica las propiedades de DATASOURCE elige “Adodc1”, y en DATAFIELD elige el campo a mostrar.

6.- Ejecuta el formulario y listo.

CONFIGURAR BOTONES DE SIGUIENTE, ANTERIOR, PRIMERO Y ULTIMO. FORMULARIO DE MOSTRAR.

SIGUIENTE:

Private Sub CmdSiguiente_Click()

Adodc1.Recordset.MoveNext

If Adodc1.Recordset.EOF Then

Adodc1.Recordset.MovePrevious

End If

End Sub

ANTERIOR:

Private Sub CmdAnterior_Click()

Adodc1.Recordset.MovePrevious

If Adodc1.Recordset.BOF Then

Adodc1.Recordset.MoveNext

End If

End Sub

PRIMERO:

Private Sub CmdPrimero_Click()

Adodc1.Recordset.MoveFirst

End Sub

ULTIMO:

Private Sub CmdUltimo_Click()

Adodc1.Recordset.MoveLast

End Sub

SALIR:

Private Sub CmdSalir_Click()

Unload Me

FrmMenu.Show

End Sub

FORMULARIO DE ALTAS

BOTON DE AGREGAR

Consideramos que las cajas de texto están desactivadas, al dar clic las activamos para que podamos escribir en ellas.

Private Sub CmdAgregar_Click()

Adodc1.Recordset.AddNew

Text1.Visible = True

Text2.Visible = True

Text3.Visible = True

Text4.Visible = True

End Sub

BOTON DE GUARDAR

Private Sub CmdGuardar_Click()

(Adodc1.Recordset.Update)

Adodc1.Recordset.MoveNext

Adodc1.Recordset.MovePrevious

(Adodc1.Refresh)

c = MsgBox("Guardado")

End Sub

SALIR:

Private Sub CmdSalir_Click()

Unload Me

FrmMenu.Show

End Sub

FORMULARIO DE BAJAS

BOTON DE MOSTRAR:

Private Sub CmdMostrar_Click()

Dim aux As String

Adodc1.Refresh

aux = UCase(Text5.Text)

Adodc1.Recordset.MoveNext

If Not Adodc1.Recordset.EOF Then

Adodc1.Recordset.Find "NOMBRE = '" & UCase(aux) & "'"

End If

If Adodc1.Recordset.EOF Then

Adodc1.Recordset.MoveFirst

Adodc1.Recordset.Find "NOMBRE = '" & UCase(aux) & "'"

If Adodc1.Recordset.EOF Then

Adodc1.Recordset.MoveLast

m = MsgBox("NO SE ENCONTRO", vbCritical)

Text5.Text = ""

Label1.Visible = False

Label2.Visible = False

Label3.Visible = False

Label4.Visible = False

Text1.Visible = False

Text2.Visible = False

Text3.Visible = False

Text4.Visible = False

Text5.SetFocus

End If

End If

Label1.Visible = True

Label2.Visible = True

Label3.Visible = True

Label4.Visible = True

Text1.Visible = True

Text2.Visible = True

Text3.Visible = True

Text4.Visible = True

End Sub

BOTON DE ELIMINAR:

Private Sub Command2_Click()

With Adodc1.Recordset

.Delete

.MoveNext

If .EOF Then .MoveLast

End With

End Sub

Private Sub Command2_Click()

x=msgbox(“ Estas seguro de Eliminar el Registro”, vbYesNo, “Alerta de Eliminación”)

if x=vbYes then

adodc1.recorset.delete

adodc1.recorset.movefirst

msgbox “Registro Eliminado Satisfactoriamente”,

else

msgbox “No se Realizó ninguna Eliminación”

endif

FORMULARIO DE CONSULTAS

BOTON DE CONSULTAR:

Private Sub CmdConsultar_Click()

Dim aux As String

Adodc1.Refresh

aux = UCase(Text5.Text)

Adodc1.Recordset.MoveNext

If Not Adodc1.Recordset.EOF Then

Adodc1.Recordset.Find "NOMBRE = '" & UCase(aux) & "'"

End If

If Adodc1.Recordset.EOF Then

Adodc1.Recordset.MoveFirst

Adodc1.Recordset.Find "NOMBRE = '" & UCase(aux) & "'"

If Adodc1.Recordset.EOF Then

Adodc1.Recordset.MoveLast

m = MsgBox("NO SE ENCONTRO", vbCritical)

Text5.Text = ""

Label1.Visible = False

Label2.Visible = False

Label3.Visible = False

Label4.Visible = False

Text1.Visible = False

Text2.Visible = False

Text3.Visible = False

Text4.Visible = False

Text5.SetFocus

End If

End If

Label1.Visible = True

Label2.Visible = True

Label3.Visible = True

Label4.Visible = True

Text1.Visible = True

Text2.Visible = True

Text3.Visible = True

...

Descargar como (para miembros actualizados)  txt (13 Kb)  
Leer 11 páginas más »
Disponible sólo en Clubensayos.com