MENDRI17 de Febrero del 2004
PreguntaPORFA SI ALGUIEN ES BUENO PROGRAMANDO....
EL SIGUIENETE CODIGO, CUANDO EJECUTO Y EN EL MSGBOX LE DIGO QUE SI....SIRVE Y SI LE DIGO QUE NO....ME DISE QUE LA OPERACION NO ESTA PERMITIDA SI EL OBJETO ESTA ABIERTO...
Private Sub List1_Click()
Dim Clave As String
Dim clave1 As String
Dim Mensaje, Estilo, Título, Respuesta
Text1.Text = List1.Text
List1.Visible = False
Clave = Text1.Text
cn.Open "inventario", "", ""
Busca = "SELECT * FROM computadora, monitor, impresora, swith where computadora.cmnusr ='" & Clave & "' or monitor.mnnsmt ='" & Clave & "' or impresora.imnsim ='" & Clave & "' or swith.swnusr= '" & Clave & "'"
Set rst = cn.Execute(Busca)
If Clave = rst!cmnusr Then
Text6.Text = rst!cmninv
guarda1 = Text6.Text
Text2.Text = "COMPUTADORA"
Text2.Enabled = False
Text8.Text = rst!cmfmto
Text12.Text = rst!cmcvdp
clv2 = Text12.Text
b2 = "select * from departamento where dpcvdp ='" & clv2 & "'"
Set rst1 = cn.Execute(b2)
Text12.Text = rst1!dpnodp
clv3 = rst1!dpcvae
b3 = "select * from area where aecvae ='" & clv3 & "'"
Set rst2 = cn.Execute(b3)
Text13.Text = rst2!aenoma
b4 = "select * from encargado where ecnusr ='" & Clave & "'"
Set rst4 = cn.Execute(b4)
Text14.Text = rst4!ecnoec
Mensaje = "IMPORTANTE: Este equipo pasará a mantenimiento..."
Estilo = vbYesNo + vbCritical + vbDefaultButton2 ' Define los botones.
Título = "Mensaje de Comprobación del Número de Serie y otros datos..."
Respuesta = MsgBox(Mensaje, Estilo, Título)
If Respuesta = vbYes Then ' El usuario eligió el botón Sí.
b5 = "select * from computadora where cmnusr ='" & Clave & "'"
rst5.LockType = adLockOptimistic
rst5.CursorType = adOpenDynamic
rst5.Open b5, cn, , , adCmdText
If rst5!cmmnto <> -1 Then
rst5!cmmnto = 1
rst5.Update
'MsgBox ("PASANDO A MANTENIMIENTO....ESPERE...")
Else
MsgBox ("EL EQUIPO YA ESTA EN MANTENIMIENTO")
End If
Else
MsgBox ("Operación cancela Comprueve sus datos...")
On Error GoTo manej
Adodc1.Recordset.Cancel
textos frmmantto, False
botones frmmantto, True
guardar.Enabled = False
cancelar.Enabled = False
bencarg.Enabled = True
cencarg.Enabled = True
Adodc1.Refresh
manej:
Exit Sub
MsgBox (Err.Description)
End If
Else
If Clave = rst!mnnsmt Then
m = True
Text6.Text = rst!mnninv
Text2.Text = "MONITOR"
Text8.Text = rst!mnfmto
Text14.Text = rst!mnnusr
clv1 = Text14.Text
b1 = "select * from encargado where ecnusr ='" & clv1 & "'"
Set rst1 = cn.Execute(b1)
Text14.Text = rst1!ecnoec
b2 = "select * from computadora where cmnusr='" & clv1 & "'"
Set rst2 = cn.Execute(b2)
Text12.Text = rst2!cmcvdp
clv2 = Text12.Text
b3 = "select * from departamento where dpcvdp='" & clv2 & "'"
Set rst3 = cn.Execute(b3)
Text12.Text = rst3!dpnodp
Text13.Text = rst3!dpcvae
clv3 = Text13.Text
b4 = "select * from area where aecvae='" & clv3 & "'"
Set rst4 = cn.Execute(b4)
Text13.Text = rst4!aenoma
Mensaje = "IMPORTANTE: Este equipo pasará a mantenimiento..."
Estilo = vbYesNo + vbCritical + vbDefaultButton2 ' Define los botones.
Título = "Mensaje de Comprobación del Número de Serie y otros datos..."
Respuesta = MsgBox(Mensaje, Estilo, Título)
If Respuesta = vbYes Then ' El usuario eligió el botón Sí.
b6 = "select * from monitor where mnnsmt ='" & Clave & "'"
rst6.LockType = adLockOptimistic
rst6.CursorType = adOpenDynamic
rst6.Open b6, cn, , , adCmdText
If rst6!mnmnto <> 1 Then
rst6!mnmnto = 1
rst6.Update
'MsgBox ("PASANDO A MANTENIMIENTO....ESPERE...")
Else
MsgBox ("EL EQUIPO YA ESTA EN MANTENIMIENTO")
End If
Else
MsgBox ("Operación cancela Comprueve sus datos...")
On Error GoTo manej1
Adodc1.Recordset.Cancel
textos frmmantto, False
botones frmmantto, True
guardar.Enabled = False
cancelar.Enabled = False
bencarg.Enabled = True
cencarg.Enabled = True
Adodc1.Refresh
manej1:
Exit Sub
MsgBox (Err.Description)
End If
Else
If Clave = rst!imnsim Then
i = True
Text6.Text = rst!imninv
Text2.Text = "IMPRESORA"
Text8.Text = rst!imfmto
'Text12.Text = rst!imninv
Text14.Text = rst!imnusr
clv1 = Text14.Text
b1 = "select * from encargado where ecnusr ='" & clv1 & "'"
Set rst1 = cn.Execute(b1)
Text14.Text = rst1!ecnoec
b2 = "select * from computadora where cmnusr='" & clv1 & "'"
Set rst2 = cn.Execute(b2)
Text12.Text = rst2!cmcvdp
clv2 = Text12.Text
b3 = "select * from departamento where dpcvdp='" & clv2 & "'"
Set rst3 = cn.Execute(b3)
Text12.Text = rst3!dpnodp
Text13.Text = rst3!dpcvae
clv3 = Text13.Text
b4 = "select * from area where aecvae='" & clv3 & "'"
Set rst4 = cn.Execute(b4)
Text13.Text = rst4!aenoma
Mensaje = "IMPORTANTE: Este equipo pasará a mantenimiento..."
Estilo = vbYesNo + vbCritical + vbDefaultButton2 ' Define los botones.
Título = "Mensaje de Comprobación del Número de Serie y otros datos..."
Respuesta = MsgBox(Mensaje, Estilo, Título)
If Respuesta = vbYes Then ' El usuario eligió el botón Sí.
b5 = "select * from impresora where imnsim ='" & Clave & "'"
rst5.LockType = adLockOptimistic
rst5.CursorType = adOpenDynamic
rst5.Open b5, cn, , , adCmdText
If rst5!immnto <> 1 Then
rst5!immnto = 1
rst5.Update
'MsgBox ("PASANDO A MANTENIMIENTO....ESPERE...")
Else
MsgBox ("EL EQUIPO YA ESTA EN MANTENIMIENTO")
End If
Else
MsgBox ("Operación cancela Comprueve sus datos...")
On Error GoTo manej2
Adodc1.Recordset.Cancel
textos frmmantto, False
botones frmmantto, True
guardar.Enabled = False
cancelar.Enabled = False
bencarg.Enabled = True
cencarg.Enabled = True
Adodc1.Refresh
manej2:
Exit Sub
MsgBox (Err.Description)
End If
Else
If Clave = rst!swnusr Then
W = True
Text6.Text = rst!swninv
Text2.Text = "SWITH"
Text8.Text = rst!swfmto
Text12.Text = rst!swubic
Text13.Text = rst!swubic
Text14.Text = "PERSONAL DE SISTEMAS"
Mensaje = "IMPORTANTE: Este equipo pasará a mantenimiento..."
Estilo = vbYesNo + vbCritical + vbDefaultButton2 ' Define los botones.
Título = "Mensaje de Comprobación del Número de Serie y otros datos..."
Respuesta = MsgBox(Mensaje, Estilo, Título)
If Respuesta = vbYes Then ' El usuario eligió el botón Sí.
b1 = "select * from swith where swnusr ='" & Clave & "'"
rst1.LockType = adLockOptimistic
rst1.CursorType = adOpenDynamic
rst1.Open b1, cn, , , adCmdText
If rst1!swmnto <> 1 Then
rst1!swmnto = 1
rst1.Update
'MsgBox ("PASANDO A MANTENIMIENTO....ESPERE...")
Else
MsgBox ("EL EQUIPO YA ESTA EN MANTENIMIENTO")
End If
Else
MsgBox ("Operación cancela Comprueve sus datos...")
On Error GoTo manej3
Adodc1.Recordset.Cancel
textos frmmantto, False
botones frmmantto, True
guardar.Enabled = False
cancelar.Enabled = False
bencarg.Enabled = True
cencarg.Enabled = True
Adodc1.Refresh
manej3:
Exit Sub
MsgBox (Err.Description)
End If
End If
End If
End If
End If
Set cn = Nothing
Set rst = Nothing
Set rst1 = Nothing
Set rst2 = Nothing
Set rst3 = Nothing
Set rst4 = Nothing
Set rst5 = Nothing
'Set rstbusca = Nothing
'Text12.Text = facturaid
'rs1.Close
End Sub
EL SIGUIENETE CODIGO, CUANDO EJECUTO Y EN EL MSGBOX LE DIGO QUE SI....SIRVE Y SI LE DIGO QUE NO....ME DISE QUE LA OPERACION NO ESTA PERMITIDA SI EL OBJETO ESTA ABIERTO...
Private Sub List1_Click()
Dim Clave As String
Dim clave1 As String
Dim Mensaje, Estilo, Título, Respuesta
Text1.Text = List1.Text
List1.Visible = False
Clave = Text1.Text
cn.Open "inventario", "", ""
Busca = "SELECT * FROM computadora, monitor, impresora, swith where computadora.cmnusr ='" & Clave & "' or monitor.mnnsmt ='" & Clave & "' or impresora.imnsim ='" & Clave & "' or swith.swnusr= '" & Clave & "'"
Set rst = cn.Execute(Busca)
If Clave = rst!cmnusr Then
Text6.Text = rst!cmninv
guarda1 = Text6.Text
Text2.Text = "COMPUTADORA"
Text2.Enabled = False
Text8.Text = rst!cmfmto
Text12.Text = rst!cmcvdp
clv2 = Text12.Text
b2 = "select * from departamento where dpcvdp ='" & clv2 & "'"
Set rst1 = cn.Execute(b2)
Text12.Text = rst1!dpnodp
clv3 = rst1!dpcvae
b3 = "select * from area where aecvae ='" & clv3 & "'"
Set rst2 = cn.Execute(b3)
Text13.Text = rst2!aenoma
b4 = "select * from encargado where ecnusr ='" & Clave & "'"
Set rst4 = cn.Execute(b4)
Text14.Text = rst4!ecnoec
Mensaje = "IMPORTANTE: Este equipo pasará a mantenimiento..."
Estilo = vbYesNo + vbCritical + vbDefaultButton2 ' Define los botones.
Título = "Mensaje de Comprobación del Número de Serie y otros datos..."
Respuesta = MsgBox(Mensaje, Estilo, Título)
If Respuesta = vbYes Then ' El usuario eligió el botón Sí.
b5 = "select * from computadora where cmnusr ='" & Clave & "'"
rst5.LockType = adLockOptimistic
rst5.CursorType = adOpenDynamic
rst5.Open b5, cn, , , adCmdText
If rst5!cmmnto <> -1 Then
rst5!cmmnto = 1
rst5.Update
'MsgBox ("PASANDO A MANTENIMIENTO....ESPERE...")
Else
MsgBox ("EL EQUIPO YA ESTA EN MANTENIMIENTO")
End If
Else
MsgBox ("Operación cancela Comprueve sus datos...")
On Error GoTo manej
Adodc1.Recordset.Cancel
textos frmmantto, False
botones frmmantto, True
guardar.Enabled = False
cancelar.Enabled = False
bencarg.Enabled = True
cencarg.Enabled = True
Adodc1.Refresh
manej:
Exit Sub
MsgBox (Err.Description)
End If
Else
If Clave = rst!mnnsmt Then
m = True
Text6.Text = rst!mnninv
Text2.Text = "MONITOR"
Text8.Text = rst!mnfmto
Text14.Text = rst!mnnusr
clv1 = Text14.Text
b1 = "select * from encargado where ecnusr ='" & clv1 & "'"
Set rst1 = cn.Execute(b1)
Text14.Text = rst1!ecnoec
b2 = "select * from computadora where cmnusr='" & clv1 & "'"
Set rst2 = cn.Execute(b2)
Text12.Text = rst2!cmcvdp
clv2 = Text12.Text
b3 = "select * from departamento where dpcvdp='" & clv2 & "'"
Set rst3 = cn.Execute(b3)
Text12.Text = rst3!dpnodp
Text13.Text = rst3!dpcvae
clv3 = Text13.Text
b4 = "select * from area where aecvae='" & clv3 & "'"
Set rst4 = cn.Execute(b4)
Text13.Text = rst4!aenoma
Mensaje = "IMPORTANTE: Este equipo pasará a mantenimiento..."
Estilo = vbYesNo + vbCritical + vbDefaultButton2 ' Define los botones.
Título = "Mensaje de Comprobación del Número de Serie y otros datos..."
Respuesta = MsgBox(Mensaje, Estilo, Título)
If Respuesta = vbYes Then ' El usuario eligió el botón Sí.
b6 = "select * from monitor where mnnsmt ='" & Clave & "'"
rst6.LockType = adLockOptimistic
rst6.CursorType = adOpenDynamic
rst6.Open b6, cn, , , adCmdText
If rst6!mnmnto <> 1 Then
rst6!mnmnto = 1
rst6.Update
'MsgBox ("PASANDO A MANTENIMIENTO....ESPERE...")
Else
MsgBox ("EL EQUIPO YA ESTA EN MANTENIMIENTO")
End If
Else
MsgBox ("Operación cancela Comprueve sus datos...")
On Error GoTo manej1
Adodc1.Recordset.Cancel
textos frmmantto, False
botones frmmantto, True
guardar.Enabled = False
cancelar.Enabled = False
bencarg.Enabled = True
cencarg.Enabled = True
Adodc1.Refresh
manej1:
Exit Sub
MsgBox (Err.Description)
End If
Else
If Clave = rst!imnsim Then
i = True
Text6.Text = rst!imninv
Text2.Text = "IMPRESORA"
Text8.Text = rst!imfmto
'Text12.Text = rst!imninv
Text14.Text = rst!imnusr
clv1 = Text14.Text
b1 = "select * from encargado where ecnusr ='" & clv1 & "'"
Set rst1 = cn.Execute(b1)
Text14.Text = rst1!ecnoec
b2 = "select * from computadora where cmnusr='" & clv1 & "'"
Set rst2 = cn.Execute(b2)
Text12.Text = rst2!cmcvdp
clv2 = Text12.Text
b3 = "select * from departamento where dpcvdp='" & clv2 & "'"
Set rst3 = cn.Execute(b3)
Text12.Text = rst3!dpnodp
Text13.Text = rst3!dpcvae
clv3 = Text13.Text
b4 = "select * from area where aecvae='" & clv3 & "'"
Set rst4 = cn.Execute(b4)
Text13.Text = rst4!aenoma
Mensaje = "IMPORTANTE: Este equipo pasará a mantenimiento..."
Estilo = vbYesNo + vbCritical + vbDefaultButton2 ' Define los botones.
Título = "Mensaje de Comprobación del Número de Serie y otros datos..."
Respuesta = MsgBox(Mensaje, Estilo, Título)
If Respuesta = vbYes Then ' El usuario eligió el botón Sí.
b5 = "select * from impresora where imnsim ='" & Clave & "'"
rst5.LockType = adLockOptimistic
rst5.CursorType = adOpenDynamic
rst5.Open b5, cn, , , adCmdText
If rst5!immnto <> 1 Then
rst5!immnto = 1
rst5.Update
'MsgBox ("PASANDO A MANTENIMIENTO....ESPERE...")
Else
MsgBox ("EL EQUIPO YA ESTA EN MANTENIMIENTO")
End If
Else
MsgBox ("Operación cancela Comprueve sus datos...")
On Error GoTo manej2
Adodc1.Recordset.Cancel
textos frmmantto, False
botones frmmantto, True
guardar.Enabled = False
cancelar.Enabled = False
bencarg.Enabled = True
cencarg.Enabled = True
Adodc1.Refresh
manej2:
Exit Sub
MsgBox (Err.Description)
End If
Else
If Clave = rst!swnusr Then
W = True
Text6.Text = rst!swninv
Text2.Text = "SWITH"
Text8.Text = rst!swfmto
Text12.Text = rst!swubic
Text13.Text = rst!swubic
Text14.Text = "PERSONAL DE SISTEMAS"
Mensaje = "IMPORTANTE: Este equipo pasará a mantenimiento..."
Estilo = vbYesNo + vbCritical + vbDefaultButton2 ' Define los botones.
Título = "Mensaje de Comprobación del Número de Serie y otros datos..."
Respuesta = MsgBox(Mensaje, Estilo, Título)
If Respuesta = vbYes Then ' El usuario eligió el botón Sí.
b1 = "select * from swith where swnusr ='" & Clave & "'"
rst1.LockType = adLockOptimistic
rst1.CursorType = adOpenDynamic
rst1.Open b1, cn, , , adCmdText
If rst1!swmnto <> 1 Then
rst1!swmnto = 1
rst1.Update
'MsgBox ("PASANDO A MANTENIMIENTO....ESPERE...")
Else
MsgBox ("EL EQUIPO YA ESTA EN MANTENIMIENTO")
End If
Else
MsgBox ("Operación cancela Comprueve sus datos...")
On Error GoTo manej3
Adodc1.Recordset.Cancel
textos frmmantto, False
botones frmmantto, True
guardar.Enabled = False
cancelar.Enabled = False
bencarg.Enabled = True
cencarg.Enabled = True
Adodc1.Refresh
manej3:
Exit Sub
MsgBox (Err.Description)
End If
End If
End If
End If
End If
Set cn = Nothing
Set rst = Nothing
Set rst1 = Nothing
Set rst2 = Nothing
Set rst3 = Nothing
Set rst4 = Nothing
Set rst5 = Nothing
'Set rstbusca = Nothing
'Text12.Text = facturaid
'rs1.Close
End Sub
