Imprimir mdb
Hola xabi
Tengo una base de datos mdb donde desde un programa meto los datos,
en ese mdb hay un "Form" (el programa de access lo tengo en ingles) supongo que sera formulario donde se ve las tablas en estilo factura con una imagen incluida, pero en el programa de visual uso las tablas para almacenar datos y no se como hacer para darle a un botón y que me imprima los datos que se ven en el programa en el formulario de la factura, aquí te pongo el programa para que veas como esta hecho y te pueda facilitar las cosas.
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Buscar_Click()
Dim criterio As String
Dim val As Boolean
Dim criterio1 As String
criterio1 = "[IdCliente]=" & Text1.Text
rs.MoveFirst
If Option1.Value = True Then
Text6.Text = ""
If Text5.Text = "" Then
MsgBox "Ingrese Numero de Cliente"
Else
criterio = "[IdCliente]=" & Text5.Text
rs.Find criterio
val = validar()
End If
End If
If Option2.Value = True Then
Text5.Text = ""
If Text6.Text = "" Then
MsgBox "Ingrese Cliente"
Else
criterio = "[Cliente] like '*" & Text6.Text & "*'"
rs.Find criterio
val = validar
End If
End If
If val = True Then
refrescar
Else
If Text5.Text <> "" Or Text6.Text <> "" Then
rs.MoveFirst
rs.Find criterio1
refrescar
MsgBox "Registro no existente"
Text5.Text = ""
Text6.Text = ""
End If
End If
End Sub
Private Sub Cancelar_Click()
rs.CancelUpdate
refrescar
desabilitar
End Sub
Private Sub Anterior_Click()
rs.MovePrevious
Posterior.Enabled = True
desabilitar
If rs.BOF = True Then
rs.MoveFirst
Primero.Enabled = False
Anterior.Enabled = False
Else
refrescar
End If
End Sub
Public Sub refrescar()
Text1.Text = rs!idcliente
Text2.Text = rs!Cliente
Text3.Text = rs!CIF
Text4.Text = rs!Direccion
Text7.Text = rs!Ciudad
Text8.Text = rs!FFactura
Text9.Text = rs!FPedido
Text10.Text = rs!Cantidad
Text11.Text = rs!Concepto
Text12.Text = rs!PUnidad
Text13.Text = rs!PTotal
Text14.Text = rs!Suma
Text15.Text = rs!Total
Text16.Text = rs!IVA
Text17.Text = rs!CP
Combo1.Text = rs!Provincia
End Sub
Private Sub Eliminar_Click()
Dim n As Integer
n = MsgBox("Esta Seguro que desea eliminar el registro?", vbYesNo, "Confirme Eliminacion")
If n = vbYes Then
rs.Delete
End If
rs.MovePrevious
rs.MoveNext
refrescar
End Sub
Private Sub Modificar_Click()
desabilitar
End Sub
Private Sub Option1_Click()
Text6.Text = ""
End Sub
Private Sub Option2_Click()
Text5.Text = ""
End Sub
Private Sub Salir_Click()
Unload Me
End Sub
Private Sub Posterior_Click()
rs.MoveNext
desabilitar
If rs.EOF = True Then
rs.MoveLast
Ultimo.Enabled = False
Posterior.Enabled = False
Else
refrescar
End If
End Sub
Private Sub Primero_Click()
rs.MoveFirst
refrescar
desabilitar
End Sub
Private Sub Ultimo_Click()
refrescar
desabilitar
End Sub
Private Sub Form_Load()
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.ConnectionString = "db1.mdb"
cn.Open
rs.Open "select * from Factura", cn, adoenkeyset, adLockOptimistic
rs.MoveFirst
refrescar
desabilitar
Option1.Value = True
End Sub
Private Sub Guardar_Click()
rs.Fields("IdCliente") = Text1.Text
rs.Fields("Cliente") = Text2.Text
rs.Fields("CIF") = Text3.Text
rs.Fields("Direccion") = Text4.Text
rs.Fields("Ciudad") = Text7.Text
rs.Fields("FFactura") = Text8.Text
rs.Fields("FPedido") = Text9.Text
rs.Fields("Cantidad") = Text10.Text
rs.Fields("Concepto") = Text11.Text
rs.Fields("PUnidad") = Text12.Text
rs.Fields("PTotal") = Text13.Text
rs.Fields("Suma") = Text14.Text
rs.Fields("Total") = Text15.Text
rs.Fields("IVA") = Text16.Text
rs.Fields("CP") = Text17.Text
rs.Fields("Provincia") = Combo1.Text
rs.Update
desabilitar
rs.MoveLast
End Sub
Private Sub Nuevo_Click()
rs.AddNew
limpiar
desabilitar
End Sub
Private Sub limpiar()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text7.Text = ""
Text8.Text = "00/00/0000"
Text9.Text = "00/00/0000"
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
Text14.Text = ""
Text15.Text = ""
Text16.Text = ""
Text17.Text = ""
Combo1.Text = "A Coruña"
End Sub
Public Sub desabilitar()
If Primero.Value = True Then
Posterior.Enabled = True
Ultimo.Enabled = True
Anterior.Enabled = False
Nuevo.Enabled = True
Guardar.Enabled = False
Cancelar.Enabled = False
Primero.Enabled = False
Modificar.Enabled = True
Else
If Nuevo.Value = True Then
Posterior.Enabled = False
Ultimo.Enabled = False
Anterior.Enabled = False
Nuevo.Enabled = False
Guardar.Enabled = True
Cancelar.Enabled = True
Primero.Enabled = False
Salir.Enabled = False
Buscar.Enabled = False
Eliminar.Enabled = False
Modificar.Enabled = False
Frame1.Enabled = False
Else
If Guardar.Value = True Or Cancelar.Value = True Then
Posterior.Enabled = True
Ultimo.Enabled = True
Anterior.Enabled = True
Nuevo.Enabled = True
Guardar.Enabled = False
Cancelar.Enabled = False
Primero.Enabled = True
Salir.Enabled = True
Buscar.Enabled = True
Eliminar.Enabled = True
Frame1.Enabled = True
Modificar.Enabled = True
Else
If Ultimo.Value = True Then
Posterior.Enabled = False
Ultimo.Enabled = False
Anterior.Enabled = True
Nuevo.Enabled = True
Guardar.Enabled = False
Cancelar.Enabled = False
Primero.Enabled = True
Else
If Modificar.Value = True Then
Posterior.Enabled = False
Ultimo.Enabled = False
Anterior.Enabled = False
Nuevo.Enabled = False
Guardar.Enabled = True
Cancelar.Enabled = True
Primero.Enabled = False
Eliminar.Enabled = False
Buscar.Enabled = False
Frame1.Enabled = False
Else
Posterior.Enabled = True
Ultimo.Enabled = True
Anterior.Enabled = True
Nuevo.Enabled = True
Guardar.Enabled = False
Cancelar.Enabled = False
Primero.Enabled = True
Eliminar.Enabled = True
Buscar.Enabled = True
End If
...
Tengo una base de datos mdb donde desde un programa meto los datos,
en ese mdb hay un "Form" (el programa de access lo tengo en ingles) supongo que sera formulario donde se ve las tablas en estilo factura con una imagen incluida, pero en el programa de visual uso las tablas para almacenar datos y no se como hacer para darle a un botón y que me imprima los datos que se ven en el programa en el formulario de la factura, aquí te pongo el programa para que veas como esta hecho y te pueda facilitar las cosas.
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Buscar_Click()
Dim criterio As String
Dim val As Boolean
Dim criterio1 As String
criterio1 = "[IdCliente]=" & Text1.Text
rs.MoveFirst
If Option1.Value = True Then
Text6.Text = ""
If Text5.Text = "" Then
MsgBox "Ingrese Numero de Cliente"
Else
criterio = "[IdCliente]=" & Text5.Text
rs.Find criterio
val = validar()
End If
End If
If Option2.Value = True Then
Text5.Text = ""
If Text6.Text = "" Then
MsgBox "Ingrese Cliente"
Else
criterio = "[Cliente] like '*" & Text6.Text & "*'"
rs.Find criterio
val = validar
End If
End If
If val = True Then
refrescar
Else
If Text5.Text <> "" Or Text6.Text <> "" Then
rs.MoveFirst
rs.Find criterio1
refrescar
MsgBox "Registro no existente"
Text5.Text = ""
Text6.Text = ""
End If
End If
End Sub
Private Sub Cancelar_Click()
rs.CancelUpdate
refrescar
desabilitar
End Sub
Private Sub Anterior_Click()
rs.MovePrevious
Posterior.Enabled = True
desabilitar
If rs.BOF = True Then
rs.MoveFirst
Primero.Enabled = False
Anterior.Enabled = False
Else
refrescar
End If
End Sub
Public Sub refrescar()
Text1.Text = rs!idcliente
Text2.Text = rs!Cliente
Text3.Text = rs!CIF
Text4.Text = rs!Direccion
Text7.Text = rs!Ciudad
Text8.Text = rs!FFactura
Text9.Text = rs!FPedido
Text10.Text = rs!Cantidad
Text11.Text = rs!Concepto
Text12.Text = rs!PUnidad
Text13.Text = rs!PTotal
Text14.Text = rs!Suma
Text15.Text = rs!Total
Text16.Text = rs!IVA
Text17.Text = rs!CP
Combo1.Text = rs!Provincia
End Sub
Private Sub Eliminar_Click()
Dim n As Integer
n = MsgBox("Esta Seguro que desea eliminar el registro?", vbYesNo, "Confirme Eliminacion")
If n = vbYes Then
rs.Delete
End If
rs.MovePrevious
rs.MoveNext
refrescar
End Sub
Private Sub Modificar_Click()
desabilitar
End Sub
Private Sub Option1_Click()
Text6.Text = ""
End Sub
Private Sub Option2_Click()
Text5.Text = ""
End Sub
Private Sub Salir_Click()
Unload Me
End Sub
Private Sub Posterior_Click()
rs.MoveNext
desabilitar
If rs.EOF = True Then
rs.MoveLast
Ultimo.Enabled = False
Posterior.Enabled = False
Else
refrescar
End If
End Sub
Private Sub Primero_Click()
rs.MoveFirst
refrescar
desabilitar
End Sub
Private Sub Ultimo_Click()
refrescar
desabilitar
End Sub
Private Sub Form_Load()
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.ConnectionString = "db1.mdb"
cn.Open
rs.Open "select * from Factura", cn, adoenkeyset, adLockOptimistic
rs.MoveFirst
refrescar
desabilitar
Option1.Value = True
End Sub
Private Sub Guardar_Click()
rs.Fields("IdCliente") = Text1.Text
rs.Fields("Cliente") = Text2.Text
rs.Fields("CIF") = Text3.Text
rs.Fields("Direccion") = Text4.Text
rs.Fields("Ciudad") = Text7.Text
rs.Fields("FFactura") = Text8.Text
rs.Fields("FPedido") = Text9.Text
rs.Fields("Cantidad") = Text10.Text
rs.Fields("Concepto") = Text11.Text
rs.Fields("PUnidad") = Text12.Text
rs.Fields("PTotal") = Text13.Text
rs.Fields("Suma") = Text14.Text
rs.Fields("Total") = Text15.Text
rs.Fields("IVA") = Text16.Text
rs.Fields("CP") = Text17.Text
rs.Fields("Provincia") = Combo1.Text
rs.Update
desabilitar
rs.MoveLast
End Sub
Private Sub Nuevo_Click()
rs.AddNew
limpiar
desabilitar
End Sub
Private Sub limpiar()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text7.Text = ""
Text8.Text = "00/00/0000"
Text9.Text = "00/00/0000"
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
Text14.Text = ""
Text15.Text = ""
Text16.Text = ""
Text17.Text = ""
Combo1.Text = "A Coruña"
End Sub
Public Sub desabilitar()
If Primero.Value = True Then
Posterior.Enabled = True
Ultimo.Enabled = True
Anterior.Enabled = False
Nuevo.Enabled = True
Guardar.Enabled = False
Cancelar.Enabled = False
Primero.Enabled = False
Modificar.Enabled = True
Else
If Nuevo.Value = True Then
Posterior.Enabled = False
Ultimo.Enabled = False
Anterior.Enabled = False
Nuevo.Enabled = False
Guardar.Enabled = True
Cancelar.Enabled = True
Primero.Enabled = False
Salir.Enabled = False
Buscar.Enabled = False
Eliminar.Enabled = False
Modificar.Enabled = False
Frame1.Enabled = False
Else
If Guardar.Value = True Or Cancelar.Value = True Then
Posterior.Enabled = True
Ultimo.Enabled = True
Anterior.Enabled = True
Nuevo.Enabled = True
Guardar.Enabled = False
Cancelar.Enabled = False
Primero.Enabled = True
Salir.Enabled = True
Buscar.Enabled = True
Eliminar.Enabled = True
Frame1.Enabled = True
Modificar.Enabled = True
Else
If Ultimo.Value = True Then
Posterior.Enabled = False
Ultimo.Enabled = False
Anterior.Enabled = True
Nuevo.Enabled = True
Guardar.Enabled = False
Cancelar.Enabled = False
Primero.Enabled = True
Else
If Modificar.Value = True Then
Posterior.Enabled = False
Ultimo.Enabled = False
Anterior.Enabled = False
Nuevo.Enabled = False
Guardar.Enabled = True
Cancelar.Enabled = True
Primero.Enabled = False
Eliminar.Enabled = False
Buscar.Enabled = False
Frame1.Enabled = False
Else
Posterior.Enabled = True
Ultimo.Enabled = True
Anterior.Enabled = True
Nuevo.Enabled = True
Guardar.Enabled = False
Cancelar.Enabled = False
Primero.Enabled = True
Eliminar.Enabled = True
Buscar.Enabled = True
End If
...
1 Respuesta
Respuesta de xabi
1