You are on page 1of 21

'Entradas

Option Explicit
Dim last, last2 As String
Dim dbsexist As Database
Dim rstexist As Recordset
Dim dbsentra As Database
Dim rstentra As Recordset

Private Sub cmdagregar_Click()


With rstentra
last = .Bookmark
.AddNew
End With
cmdeliminar.Enabled = False
cmdbuscar.Enabled = False
cmdeditar.Enabled = False
End Sub

Private Sub cmdbuscar_Click()


Dim last4 As String
Dim f As String * 10
Dim Message, Title, Default
Message = "Entrada a buscar" ' Set prompt.
Title = "Sistema de Inventarios" ' Set title.
Default = txtfecha ' Set default.
' Display message, title, and default value.
f = InputBox(Message, Title, Default)
With rstentra
.Index = "entra_nn"
last4 = .Bookmark
.Seek "=", n, m, f
If .NoMatch Then
.Bookmark = last4
MsgBox "Esta entrada no EXISTE!!!"
Else
txtfecha = .Fields("fecha_ent")
txthora = .Fields("hora_ent")
txtcantidad = .Fields("cantidad_ent")
End If
.Index = ""
'MsgBox .Fields("num_prod") & .Fields("num_tienda")
End With
End Sub

Private Sub cmdcancelar_Click()


With rstentra
.Bookmark = last
End With
End Sub

Private Sub cmdeditar_Click()


With rstentra
last = .Bookmark
.Edit
End With
cmdagregar.Enabled = False
cmdeliminar.Enabled = False
cmdeditar.Enabled = False
cmdbuscar.Enabled = False
End Sub

Private Sub cmdeliminar_Click()


If MsgBox("Deseas Eliminar la Entrada?", vbQuestion + vbYesNo) = vbYes Then
With rstentra
.Delete
.MovePrevious
End With
End If
End Sub

Private Sub cmdgrabar_Click()


On Error GoTo errordbf4
With rstentra
With rstexist
last2 = .Bookmark
.Seek "=", n, m 'n=productos m=tienda
If .NoMatch Then
.Bookmark = last2
MsgBox "Este producto no tiene EXISTENCIA"
Else
.Edit
.Fields("fecha") = txtfecha
.Fields("cantidad_exi") = .Fields("cantidad_exi") + txtcantidad
.Update
End If
End With
.Fields("num_prod") = n
.Fields("num_tienda") = m
.Fields("fecha_ent") = txtfecha
.Fields("hora_ent") = txthora
.Fields("cantidad_ent") = txtcantidad
.Update
On Error GoTo 0
End With
cmdagregar.Enabled = True
cmdeliminar.Enabled = True
cmdeditar.Enabled = True
cmdbuscar.Enabled = True
errordbf4:
'MsgBox Err.Number 'muestra numero de error
If Err.Number = 0 Then
MsgBox "Producto Actualizado!!!"
End If
If Err.Number = 3058 Then 'campos sin valor
MsgBox "No puedes dejar en blanco el NUMERO DE LA TIENDA!!!"
End If
If Err.Number = 3022 Then 'key repetida
MsgBox "El número de tienda ya EXISTE!!!"
End If
End Sub

Private Sub cmdsalir_Click()


Unload Me
End Sub

Private Sub cmdselect_Click()


Dim pos As Integer
'filtra los productos de una tienda
pos = n.Text
Select Case pos
Case 1
dat_productos.RecordSource = "select *from productos where mid(tie_prod,1,1)='*' "
Case 2
dat_productos.RecordSource = "select *from productos where mid(tie_prod,2,1)='*' "
Case 3
dat_productos.RecordSource = "select *from productos where mid(tie_prod,3,1)='*' "
Case 4
dat_productos.RecordSource = "select *from productos where mid(tie_prod,4,1)='*' "
Case 5
dat_productos.RecordSource = "select *from productos where mid(tie_prod,5,1)='*' "
Case 6
dat_productos.RecordSource = "select *from productos where mid(tie_prod,6,1)='*' "
Case 7
dat_productos.RecordSource = "select *from productos where mid(tie_prod,7,1)='*' "
Case 8
dat_productos.RecordSource = "select *from productos where mid(tie_prod,8,1)='*' "
Case 9
dat_productos.RecordSource = "select *from productos where mid(tie_prod,9,1)='*' "
Case 10
dat_productos.RecordSource = "select *from productos where mid(tie_prod,10,1)='*' "
Case 11
dat_productos.RecordSource = "select *from productos where mid(tie_prod,11,1)='*' "
Case 12
dat_productos.RecordSource = "select *from productos where mid(tie_prod,12,1)='*' "
Case 13
dat_productos.RecordSource = "select *from productos where mid(tie_prod,13,1)='*' "
Case 14
dat_productos.RecordSource = "select *from productos where mid(tie_prod,14,1)='*' "
Case 15
dat_productos.RecordSource = "select *from productos where mid(tie_prod,15,1)='*' "
Case 16
dat_productos.RecordSource = "select *from productos where mid(tie_prod,16,1)='*' "
Case 17
dat_productos.RecordSource = "select *from productos where mid(tie_prod,17,1)='*' "
Case 18
dat_productos.RecordSource = "select *from productos where mid(tie_prod,18,1)='*' "
Case 19
dat_productos.RecordSource = "select *from productos where mid(tie_prod,19,1)='*' "
Case 20
dat_productos.RecordSource = "select *from productos where mid(tie_prod,20,1)='*' "
End Select
dat_productos.Refresh
End Sub

Private Sub Form_Load()


Dim fecha As String
Dim hora
'linkea entradas
Set dbsentra = OpenDatabase("c:\sistema de inventario\archivos sistema.mdb")
Set rstentra = dbsentra.OpenRecordset("entradas", dbOpenTable)
'linkea existencias
Set dbsexist = OpenDatabase("c:\sistema de inventario\archivos sistema.mdb")
Set rstexist = dbsexist.OpenRecordset("existencia", dbOpenTable)
With rstexist
.Index = "existen"
End With
fecha = Date
fecha = Format(fecha, "dd/mm/yyyy")
txtfecha = fecha
hora = Time
txthora = hora
frm_entradas.Width = 6705
frm_entradas.Height = 7080
frm_entradas.Left = 2520
End Sub

'Productos
Option Explicit
Dim last As String
Dim last2 As String
Dim dbsprod As Database 'productos
Dim rstprod As Recordset 'recordset productos
Dim dbsexist As Database
Dim rstexist As Recordset
Dim cad
Dim tipo As String * 1

Private Sub cmdagregar_Click()


With rstprod
last = .Bookmark
.AddNew
End With
cmdeliminar.Enabled = False
cmdeditar.Enabled = False
cmdbuscar.Enabled = False
End Sub

Private Sub cmdagregare_Click()


With rstexist
last2 = .Bookmark
.AddNew
End With
End Sub

Private Sub cmdbuscar_Click()


Dim wbusca As String * 10
Dim Message, Title, Default, MyValue
Message = "Número de producto a buscar" ' Set prompt.
Title = "Sistema de Inventarios" ' Set title.
Default = "1" ' Set default.
' Display message, title, and default value.
wbusca = InputBox(Message, Title, Default)
'MsgBox wbusca
With rstprod
last = .Bookmark
.Seek "=", wbusca
If .NoMatch Then
.Bookmark = last
MsgBox "Esta tienda no EXISTE!!!"
End If
End With
End Sub

Private Sub cmdcancelar_Click()


On Error GoTo errorc
With rstprod
.Bookmark = last
End With
On Error GoTo 0
cmdeliminar.Enabled = True
cmdeditar.Enabled = True
cmdbuscar.Enabled = True
cmdagregar.Enabled = True
errorc:
If Err.Number = 3251 Then
MsgBox "Error. Operación no valida en el sistema!!!"
End If
End Sub

Private Sub cmdeditar_Click()


With rstprod
.Edit
End With
cmdeliminar.Enabled = False
cmdeditar.Enabled = False
cmdbuscar.Enabled = False
cmdagregar.Enabled = False
End Sub

Private Sub cmdeliminar_Click()


If MsgBox("Deseas Eliminar la Tienda?", vbQuestion + vbYesNo, "Eliminar Tienda:" & txtnumero.Text) =
vbYes Then
With rstprod
.Delete
.MovePrevious
End With
End If
End Sub

Private Sub cmdgrabar_Click()


On Error GoTo errordbf2
With rstprod
.Fields("tip_prod") = tipo
.Fields("fec_prod") = txtfecha
.Fields("tie_prod") = cad
.Update
cad = " "
End With
On Error GoTo 0
cmdagregar.Enabled = True
cmdeliminar.Enabled = True
cmdeditar.Enabled = True
cmdbuscar.Enabled = True
errordbf2:
'MsgBox Err.Number 'muestra numero de error
If Err.Number = 0 Then
MsgBox "Producto Actualizado!!!"
End If
If Err.Number = 3058 Then 'campos sin valor
MsgBox "No puedes dejar en blanco el NUMERO DE LA TIENDA!!!"
End If
If Err.Number = 3022 Then 'key repetida
MsgBox "El número de tienda ya EXISTE!!!"
End If
End Sub

Private Sub cmdgrabare_Click()


Dim var, i, num
On Error GoTo errordbf3
var = txttienda.Text
num = Val(var)
For i = 1 To 20
If Len(cad) = 0 Then
cad = " "
End If
If i = num Then
Mid(cad, var, 1) = "*"
End If
Next i
With rstexist
.Fields("num_prod") = txtnumero
.Fields("num_tienda") = txttienda
.Fields("fecha") = txtfechae
.Fields("cantidad_exi") = Val(txtcantidade.Text)
.Fields("ajuste_exi") = Val(txtajuste.Text)
.Update
End With
On Error GoTo 0
errordbf3:
'MsgBox Err.Number 'muestra numero de error
MsgBox "Existencia grabada!!!"
End Sub

Private Sub cmdsalir_Click()


Unload Me
End Sub

Private Sub Form_Load()


Dim fecha As String
'productos
Set dbsprod = OpenDatabase("c:\sistema de inventario\archivos sistema.mdb")
Set rstprod = dbsprod.OpenRecordset("productos", dbOpenTable)
Set dat_productos.Recordset = rstprod
With rstprod
.Index = "productos_num"
End With
'textbox de productos
txtnumero.DataField = "num_prod"
txtmarca.DataField = "mar_prod"
txtdescripcion.DataField = "des_prod"
txtcapacidad.DataField = "cap_prod"
txtprecio.DataField = "pre_prod"
'existencias
Set dbsexist = OpenDatabase("c:\sistema de inventario\archivos sistema.mdb")
Set rstexist = dbsexist.OpenRecordset("existencia", dbOpenTable)
Set dat_existencia.Recordset = rstprod
With rstexist
.Index = ""
End With
'fecha p/ el 2000
fecha = Date
fecha = Format(fecha, "dd/mm/yyyy")
txtfecha = fecha
txtfechae = txtfecha
frm_producto.Height = 7740
frm_producto.Left = 2550
frm_producto.Width = 6330
End Sub

Private Sub opcrefacciones_Click()


tipo = "R"
End Sub

Private Sub optaceite_Click()


tipo = "A"
End Sub

Private Sub optfiltro_Click()


tipo = "F"
End Sub

'Reportes especificos
Option Explicit
Dim dbs1 As Database
Dim rst1 As Recordset
Dim tip As String * 1

Private Sub cmdimprimir_Click()


If opttiras.Value = True Then
End If
End Sub

Private Sub cmdsalir_Click()


Unload Me
End Sub

Private Sub cheaceite_Click()


tip = "A"
End Sub

Private Sub chefiltros_Click()


tip = "F"
End Sub

Private Sub cherefacciones_Click()


tip = "R"
End Sub

Private Sub Form_Load()


Dim fecha
Set dbs1 = OpenDatabase("c:\sistema de inventario\archivos sistema.mdb")
fecha = Date
fecha = Format(fecha, "dd/mm/yyyy")
txtfechai = fecha
txtfechaf = fecha
frm_reporte.Height = 3915
frm_reporte.Left = 2940
frm_reporte.Width = 6255
End Sub

Public Sub re_tiras()


Dim t As Integer
t = Val(n.Text)
Set rst1 = dbs1.OpenRecordset("productos", dbOpenTable)
With rst1
.MoveFirst
Do While Not .EOF
If Mid(.Fields("tie_prod"), t, 1) = "*" And .Fields("tip_prod") = tip Then
Printer.Print "MARCA:" & .Fields("mar_prod") & " DESCRIPCION:" & .Fields("des_prod") & "
CAPACIDAD:" & .Fields("cap_prod") & "_____________ " & "____________"
Printer.CurrentX = 1
End If
.MoveNext
Loop
Printer.EndDoc
End With
End Sub

Public Sub re_entrada()


Dim rst2 As Recordset
Dim t, m As Integer
Dim rfecha, tfecha1, tfecha2
t = Val(n.Text)
Set rst1 = dbs1.OpenRecordset("productos", dbOpenTable)
Set rst2 = dbs1.OpenRecordset("entradas", dbOpenTable)
With rst2
.Index = "entra_nn"
End With
With rst1
.MoveFirst
Do While Not .EOF
If Mid(.Fields("tie_prod"), t, 1) = "*" And .Fields("tip_prod") = tip Then
m = .Fields("num_prod")
With rst2
.MoveFirst
Do While Not .EOF
If (.Fields("num_prod") = m And .Fields("num_prod") = n) Then
rfecha = CDate(.Fields("fecha_ent"))
tfecha1 = CDate(txtfechai.Text)
tfecha2 = CDate(txtfechaf.Text)
If rfecha >= tfecha1 And rfecha <= tfecha2 Then
Printer.Print "MARCA:" & rst1.Fields("mar_prod") & " DESCRIPCION:" &
rst1.Fields("des_prod") & " CAPACIDAD:" & rst1.Fields("cap_prod") & " ENTRADA:" &
.Fields("cantidad_ent")
Printer.CurrentX = 1
End If
End If
.MoveNext
Loop
End With
End If
.MoveNext
Loop
Printer.EndDoc
End With
End Sub

Public Sub re_salida()


Dim rst2 As Recordset
Dim t, m As Integer
Dim rfecha, tfecha1, tfecha2
t = Val(n.Text)
Set rst1 = dbs1.OpenRecordset("productos", dbOpenTable)
Set rst2 = dbs1.OpenRecordset("salidas", dbOpenTable)
With rst2
.Index = "sale_nn"
End With
With rst1
.MoveFirst
Do While Not .EOF
If Mid(.Fields("tie_prod"), t, 1) = "*" And .Fields("tip_prod") = tip Then
m = .Fields("num_prod")
With rst2
.MoveFirst
Do While Not .EOF
If (.Fields("num_prod") = m And .Fields("num_prod") = n) Then
rfecha = CDate(.Fields("fecha_sal"))
tfecha1 = CDate(txtfechai.Text)
tfecha2 = CDate(txtfechaf.Text)
If rfecha >= tfecha1 And rfecha <= tfecha2 Then
Printer.Print "MARCA:" & rst1.Fields("mar_prod") & " DESCRIPCION:" &
rst1.Fields("des_prod") & " CAPACIDAD:" & rst1.Fields("cap_prod") & " ENTRADA:" &
.Fields("cantidad_ent")
Printer.CurrentX = 1
End If
End If
.MoveNext
Loop
End With
End If
.MoveNext
Loop
Printer.EndDoc
End With
End Sub

Public Sub re_inventa()


Dim rst2, rst3, rst4 As Recordset
Dim rfecha, tfecha1, tfecha2
Dim exini, entra, salida As Long
Dim t, m As Integer
Set rst1 = dbs1.OpenRecordset("productos", dbOpenTable)
Set rst2 = dbs1.OpenRecordset("entradas", dbOpenTable)
Set rst3 = dbs1.OpenRecordset("salidas", dbOpenTable)
Set rst4 = dbs1.OpenRecordset("existencia", dbOpenTable)
t = Val(n.Text)
tfecha1 = CDate(txtfechai)
tfecha2 = CDate(txtfechaf)
With rst1
.MoveFirst
Do While Not .EOF
If Mid(.Fields("tie_prod"), t, 1) = "*" And .Fields("tip_prod") = tip Then
m = .Fields("num_prod")
With rst4
.Index = "existen"
.Seek "=", m, t
If .NoMatch Then
exini = 0
Else
exini = .Fields("cantidad_exi")
End If
End With
With rst2
.Index = "entra_nn"
.Seek "=", m, t
If .NoMatch Then
Else
rfecha = CDate(.Fields("fecha_ent"))
Do While m = .Fields("num_prod") And t = .Fields("num_tienda")
If rfecha >= tfecha1 And rfecha <= tfecha2 Then
entra = entra + .Fields("cantidad_exi")
End If
.MoveNext
Loop
End If
End With
With rst3
.Index = "sale_nn"
.Seek "=", m, t
If .NoMatch Then
Else
rfecha = CDate(.Fields("fecha_sal"))
Do While m = .Fields("num_prod") And t = .Fields("num_tienda")
If rfecha >= tfecha1 And rfecha <= tfecha2 Then
salida = salida + .Fields("cantidad_sal")
End If
.MoveNext
Loop
End If
End With
Printer.Print .Fields("mar_prod") & .Fields("des_prod") & .Fields("cap_prod") & Str(exini) & Str(entra)
& Str(exini + entra) & Str(salida) & Str(((exini + entra) - salida)) & .Fields("pre_prod") &
Str(.Fields("pre_prod") * ((exini + entra) - salida))
End If
exini = 0
entra = 0
salida = 0
.MoveNext
Loop
Printer.EndDoc
End With
End Sub

'Reportes especificos
Option Explicit
Dim dbs1 As Database
Dim rst1 As Recordset

Private Sub cmdimprimir_Click()


If opttiendas.Value = True Then
report_tienda
End If
If optproductos.Value = True Then
report_prodxt
End If
If opttiras.Value = True Then
report_tirasxt
End If
If optentradas.Value = True Then
report_entxt
End If
If optsalidas.Value = True Then
report_salxt
End If
If optinventario.Value = True Then
inven_g
End If
End Sub

Private Sub cmdsalir_Click()


Unload Me
End Sub

Private Sub Form_Load()


Dim fecha
Set dbs1 = OpenDatabase("c:\sistema de inventario\archivos sistema.mdb")
fecha = Date
fecha = Format(fecha, "dd/mm/yyyy")
txtfechai = fecha
txtfechaf = fecha
frm_reportg.Width = 6150
frm_reportg.Height = 3660
frm_reportg.Left = 2940
End Sub

Public Sub report_tienda() 'concentrado de tiendas


Dim p As Printer
Set rst1 = dbs1.OpenRecordset("tiendas", dbOpenTable)
With rst1
.MoveFirst
Do While Not .EOF
Printer.Print "NUMERO:" & .Fields("num_tienda") & " NOMBRE:" & .Fields("nom_tienda") & "
DIRECCION:" & .Fields("dir_tienda")
Printer.CurrentX = 1
.MoveNext
Loop
Printer.EndDoc
End With
End Sub

Public Sub report_prodxt() 'concentrado de prod x tienda


Dim t As Integer
t = Val(n.Text)
Set rst1 = dbs1.OpenRecordset("productos", dbOpenTable)
With rst1
.MoveFirst
Do While Not .EOF
If Mid(.Fields("tie_prod"), t, 1) = "*" Then
Printer.Print "NUMERO:" & .Fields("num_prod") & " TIPO:" & .Fields("tip_prod") & " MARCA:" &
.Fields("mar_prod") & " DESCRIPCION:" & .Fields("des_prod") & " CAPACIDAD:" & .Fields("cap_prod")
& " PRECIO:" & .Fields("pre_prod")
Printer.CurrentX = 1
End If
.MoveNext
Loop
Printer.EndDoc
End With
End Sub

Public Sub report_tirasxt() 'concentrado de tiras


Dim t As Integer
t = Val(n.Text)
Set rst1 = dbs1.OpenRecordset("productos", dbOpenTable)
With rst1
.MoveFirst
Do While Not .EOF
If Mid(.Fields("tie_prod"), t, 1) = "*" Then
Printer.Print "MARCA:" & .Fields("mar_prod") & " DESCRIPCION:" & .Fields("des_prod") & "
CAPACIDAD:" & .Fields("cap_prod") & "_____________ " & "____________"
Printer.CurrentX = 1
End If
.MoveNext
Loop
Printer.EndDoc
End With
End Sub

Public Sub report_entxt() 'concentrado de entras x t


Dim rst2 As Recordset
Dim t, m As Integer
Dim rfecha, tfecha1, tfecha2
t = Val(n.Text)
Set rst1 = dbs1.OpenRecordset("productos", dbOpenTable)
Set rst2 = dbs1.OpenRecordset("entradas", dbOpenTable)
With rst2
.Index = "entra_nn"
End With
With rst1
.MoveFirst
Do While Not .EOF
If Mid(.Fields("tie_prod"), t, 1) = "*" Then
m = .Fields("num_prod")
With rst2
.MoveFirst
Do While Not .EOF
If (.Fields("num_prod") = m And .Fields("num_prod") = n) Then
rfecha = CDate(.Fields("fecha_ent"))
tfecha1 = CDate(txtfechai.Text)
tfecha2 = CDate(txtfechaf.Text)
If rfecha >= tfecha1 And rfecha <= tfecha2 Then
Printer.Print "MARCA:" & rst1.Fields("mar_prod") & " DESCRIPCION:" &
rst1.Fields("des_prod") & " CAPACIDAD:" & rst1.Fields("cap_prod") & " ENTRADA:" &
.Fields("cantidad_ent")
Printer.CurrentX = 1
End If
End If
.MoveNext
Loop
End With
End If
.MoveNext
Loop
Printer.EndDoc
End With
End Sub

Public Sub report_salxt() 'concentrado de salidas x t


Dim rst2 As Recordset
Dim t, m As Integer
Dim rfecha, tfecha1, tfecha2
t = Val(n.Text)
Set rst1 = dbs1.OpenRecordset("productos", dbOpenTable)
Set rst2 = dbs1.OpenRecordset("salidas", dbOpenTable)
With rst2
.Index = "sale_nn"
End With
With rst1
.MoveFirst
Do While Not .EOF
If Mid(.Fields("tie_prod"), t, 1) = "*" Then
m = .Fields("num_prod")
With rst2
.MoveFirst
Do While Not .EOF
If (.Fields("num_prod") = m And .Fields("num_prod") = n) Then
rfecha = CDate(.Fields("fecha_sal"))
tfecha1 = CDate(txtfechai.Text)
tfecha2 = CDate(txtfechaf.Text)
If rfecha >= tfecha1 And rfecha <= tfecha2 Then
Printer.Print "MARCA:" & rst1.Fields("mar_prod") & " DESCRIPCION:" &
rst1.Fields("des_prod") & " CAPACIDAD:" & rst1.Fields("cap_prod") & " ENTRADA:" &
.Fields("cantidad_ent")
Printer.CurrentX = 1
End If
End If
.MoveNext
Loop
End With
End If
.MoveNext
Loop
Printer.EndDoc
End With
End Sub

Public Sub inven_g() 'inventario de una tienda


Dim rst2, rst3, rst4 As Recordset
Dim rfecha, tfecha1, tfecha2
Dim exini, entra, salida As Long
Dim t, m As Integer
Set rst1 = dbs1.OpenRecordset("productos", dbOpenTable)
Set rst2 = dbs1.OpenRecordset("entradas", dbOpenTable)
Set rst3 = dbs1.OpenRecordset("salidas", dbOpenTable)
Set rst4 = dbs1.OpenRecordset("existencia", dbOpenTable)
t = Val(n.Text)
tfecha1 = CDate(txtfechai)
tfecha2 = CDate(txtfechaf)
With rst1
.MoveFirst
Do While Not .EOF
If Mid(.Fields("tie_prod"), t, 1) = "*" Then
m = .Fields("num_prod")
With rst4
.Index = "existen"
.Seek "=", m, t
If .NoMatch Then
exini = 0
Else
exini = .Fields("cantidad_exi")
End If
End With
With rst2
.Index = "entra_nn"
.Seek "=", m, t
If .NoMatch Then
Else
rfecha = CDate(.Fields("fecha_ent"))
Do While m = .Fields("num_prod") And t = .Fields("num_tienda")
If rfecha >= tfecha1 And rfecha <= tfecha2 Then
entra = entra + .Fields("cantidad_exi")
End If
.MoveNext
Loop
End If
End With
With rst3
.Index = "sale_nn"
.Seek "=", m, t
If .NoMatch Then
Else
rfecha = CDate(.Fields("fecha_sal"))
Do While m = .Fields("num_prod") And t = .Fields("num_tienda")
If rfecha >= tfecha1 And rfecha <= tfecha2 Then
salida = salida + .Fields("cantidad_sal")
End If
.MoveNext
Loop
End If
End With
Printer.Print .Fields("mar_prod") & .Fields("des_prod") & .Fields("cap_prod") & Str(exini) & Str(entra)
& Str(exini + entra) & Str(salida) & Str(((exini + entra) - salida)) & .Fields("pre_prod") &
Str(.Fields("pre_prod") * ((exini + entra) - salida))
End If
exini = 0
entra = 0
salida = 0
.MoveNext
Loop
Printer.EndDoc
End With
End Sub

'Salidas
Option Explicit
Dim last, last2 As String
Dim dbsexist As Database
Dim rstexist As Recordset
Dim dbssale As Database
Dim rstsale As Recordset

Private Sub cmdagregar_Click()


With rstsale
last = .Bookmark
.AddNew
End With
cmdeliminar.Enabled = False
cmdbuscar.Enabled = False
cmdeditar.Enabled = False
End Sub

Private Sub cmdbuscar_Click()


Dim last4 As String
Dim f As String * 10
Dim Message, Title, Default
Message = "Salida a buscar" ' Set prompt.
Title = "Sistema de Inventarios" ' Set title.
Default = txtfecha ' Set default.
' Display message, title, and default value.
f = InputBox(Message, Title, Default)
With rstsale
.Index = "sale_nn"
last4 = .Bookmark
.Seek "=", n, m, f
If .NoMatch Then
.Bookmark = last4
MsgBox "Esta salida no EXISTE!!!"
Else
txtfecha = .Fields("fecha_ent")
txthora = .Fields("hora_ent")
txtcantidad = .Fields("cantidad_ent")
End If
.Index = ""
'MsgBox .Fields("num_prod") & .Fields("num_tienda")
End With
End Sub

Private Sub cmdcancelar_Click()


With rstsale
.Bookmark = last
End With
End Sub

Private Sub cmdeditar_Click()


With rstsale
last = .Bookmark
.Edit
End With
cmdagregar.Enabled = False
cmdeliminar.Enabled = False
cmdeditar.Enabled = False
cmdbuscar.Enabled = False
End Sub

Private Sub cmdeliminar_Click()


If MsgBox("Deseas Eliminar la Salida?", vbQuestion + vbYesNo) = vbYes Then
With rstsale
.Delete
.MovePrevious
End With
End If
End Sub

Private Sub cmdgrabar_Click()


On Error GoTo errordbf4
With rstsale
With rstexist
last2 = .Bookmark
.Seek "=", n, m 'n=productos m=tienda
If .NoMatch Then
.Bookmark = last2
MsgBox "Este producto no tiene EXISTENCIA"
Else
.Edit
.Fields("fecha") = txtfecha
.Fields("cantidad_exi") = .Fields("cantidad_exi") - txtcantidad
.Update
End If
End With
.Fields("num_prod") = n
.Fields("num_tienda") = m
.Fields("fecha_sal") = txtfecha
.Fields("hora_sal") = txthora
.Fields("cantidad_sal") = txtcantidad
.Update
On Error GoTo 0
End With
cmdagregar.Enabled = True
cmdeliminar.Enabled = True
cmdeditar.Enabled = True
cmdbuscar.Enabled = True
errordbf4:
'MsgBox Err.Number 'muestra numero de error
If Err.Number = 0 Then
MsgBox "Producto Actualizado!!!"
End If
If Err.Number = 3058 Then 'campos sin valor
MsgBox "No puedes dejar en blanco el NUMERO DE LA TIENDA!!!"
End If
If Err.Number = 3022 Then 'key repetida
MsgBox "El número de tienda ya EXISTE!!!"
End If
End Sub

Private Sub cmdsalir_Click()


Unload Me
End Sub

Private Sub cmdselect_Click()


Dim pos As Integer
'filtra los productos de una tienda
pos = n.Text
Select Case pos
Case 1
dat_productos.RecordSource = "select *from productos where mid(tie_prod,1,1)='*' "
Case 2
dat_productos.RecordSource = "select *from productos where mid(tie_prod,2,1)='*' "
Case 3
dat_productos.RecordSource = "select *from productos where mid(tie_prod,3,1)='*' "
Case 4
dat_productos.RecordSource = "select *from productos where mid(tie_prod,4,1)='*' "
Case 5
dat_productos.RecordSource = "select *from productos where mid(tie_prod,5,1)='*' "
Case 6
dat_productos.RecordSource = "select *from productos where mid(tie_prod,6,1)='*' "
Case 7
dat_productos.RecordSource = "select *from productos where mid(tie_prod,7,1)='*' "
Case 8
dat_productos.RecordSource = "select *from productos where mid(tie_prod,8,1)='*' "
Case 9
dat_productos.RecordSource = "select *from productos where mid(tie_prod,9,1)='*' "
Case 10
dat_productos.RecordSource = "select *from productos where mid(tie_prod,10,1)='*' "
Case 11
dat_productos.RecordSource = "select *from productos where mid(tie_prod,11,1)='*' "
Case 12
dat_productos.RecordSource = "select *from productos where mid(tie_prod,12,1)='*' "
Case 13
dat_productos.RecordSource = "select *from productos where mid(tie_prod,13,1)='*' "
Case 14
dat_productos.RecordSource = "select *from productos where mid(tie_prod,14,1)='*' "
Case 15
dat_productos.RecordSource = "select *from productos where mid(tie_prod,15,1)='*' "
Case 16
dat_productos.RecordSource = "select *from productos where mid(tie_prod,16,1)='*' "
Case 17
dat_productos.RecordSource = "select *from productos where mid(tie_prod,17,1)='*' "
Case 18
dat_productos.RecordSource = "select *from productos where mid(tie_prod,18,1)='*' "
Case 19
dat_productos.RecordSource = "select *from productos where mid(tie_prod,19,1)='*' "
Case 20
dat_productos.RecordSource = "select *from productos where mid(tie_prod,20,1)='*' "
End Select
dat_productos.Refresh
End Sub

Private Sub Form_Load()


Dim fecha As String
Dim hora
'linkea salidas
Set dbssale = OpenDatabase("c:\sistema de inventario\archivos sistema.mdb")
Set rstsale = dbssale.OpenRecordset("salidas", dbOpenTable)
'linkea existencias
Set dbsexist = OpenDatabase("c:\sistema de inventario\archivos sistema.mdb")
Set rstexist = dbsexist.OpenRecordset("existencia", dbOpenTable)
With rstexist
.Index = "existen"
End With
fecha = Date
fecha = Format(fecha, "dd/mm/yyyy")
txtfecha = fecha
hora = Time
txthora = hora
frm_salidas.Width = 6540
frm_salidas.Height = 6990
frm_salidas.Left = 2520
End Sub
'Tiendas
Option Explicit
Private last As String
Dim dbstienda As Database
Dim rsttienda As Recordset

Private Sub cmdaltas_Click()


With rsttienda
last = .Bookmark
.AddNew
End With
cmdeliminar.Enabled = False
cmdeditar.Enabled = False
cmdconsultar.Enabled = False
End Sub

Private Sub cmdcancelar_Click()


On Error GoTo error1
With rsttienda
.Bookmark = last
End With
On Error GoTo 0
cmdaltas.Enabled = True
cmdeliminar.Enabled = True
cmdconsultar.Enabled = True
cmdeditar.Enabled = True
error1:
If Err.Number = 3251 Then
MsgBox "Error. Operación de valida en el sistema!!!"
End If
'End If
End Sub

Private Sub cmdconsultar_Click()


Dim wbusca As String * 10
Dim Message, Title, Default, MyValue
Message = "Número de tienda a buscar" ' Set prompt.
Title = "Sistema de Inventarios" ' Set title.
Default = "1" ' Set default.
' Display message, title, and default value.
wbusca = InputBox(Message, Title, Default)
'MsgBox wbusca
With rsttienda
last = .Bookmark
.Seek "=", wbusca
If .NoMatch Then
.Bookmark = last
MsgBox "Esta tienda no EXISTE!!!"
End If
End With
End Sub

Private Sub cmdeditar_Click()


With rsttienda
.Edit
End With
cmdaltas.Enabled = False
cmdeliminar.Enabled = False
cmdconsultar.Enabled = False
cmdeditar.Enabled = True
End Sub

Private Sub cmdeliminar_Click()


If MsgBox("Deseas Eliminar la Tienda?", vbQuestion + vbYesNo, "Eliminar Tienda:" & txtnumero.Text) =
vbYes Then
With rsttienda
.Delete
.MovePrevious
End With
End If
End Sub

Private Sub cmdgradar_Click()


On Error GoTo errordbf2
With rsttienda
.Update
End With
On Error GoTo 0
cmdaltas.Enabled = True
cmdeliminar.Enabled = True
cmdeditar.Enabled = True
cmdconsultar.Enabled = True
errordbf2:
'MsgBox Err.Number 'muestra numero de error
If Err.Number = 0 Then
MsgBox "No haz realizado ningun cambio!!!"
End If
If Err.Number = 3058 Then 'campos sin valor
MsgBox "No puedes dejar en blanco el NUMERO DE LA TIENDA!!!"
End If
If Err.Number = 3022 Then 'key repetida
MsgBox "El número de tienda ya EXISTE!!!"
End If
End Sub

Private Sub cmdsalir_Click()


Unload Me
End Sub

Private Sub Form_Load()


Set dbstienda = OpenDatabase("c:\sistema de inventario\archivos sistema.mdb")
Set rsttienda = dbstienda.OpenRecordset("tiendas", dbOpenTable)
Set dat_tienda.Recordset = rsttienda
With rsttienda
.Index = "tienda_num"
End With
txtnumero.DataField = "num_tienda"
txtnombre.DataField = "nom_tienda"
txtdireccion.DataField = "dir_tienda"
txttelefono.DataField = "tel_tienda"
txtrep.DataField = "rep_tienda"
frm_tiendas.Width = 6510
frm_tiendas.Height = 6000
frm_tiendas.Left = 2940
End Sub

You might also like