Visual Basic 6.0
Hola! Tengo un problema, estoy hacien do un programa en VB6.0 con Access 2007 que me permita guardar datos en la base de datos y me sale el siguiente error: "Variable de tipo Object o la variable de bloque With no está establecida"
elcodigo es el siguiente:
Private Sub Command5_Click()
On Error GoTo ControlError:
Conexion.Open CadenaConexion
CadenaSql = "Insert Into Personal(codigo,Nombres,Apellido,DocdeIdentidad,Tipo,Edad,FechadeNacimiento,Domicilio,Telefono,E-Mail,Taller,Categoria) " & _
"Values(" & Text8 & ",'" & Text1 & "','" & _
Text6 & "','" & Text2 & "','" & _
Combo2 & "','" & Combo1 & "','" & _
Text7 & "','" & Text3 & "','" & _
Text4 & "','" & Text5 & "','" & _
Combo4 & "','" & Combo3 & "')"
If (Text8 <> "" And Text1 <> "" And Text6 <> "" And Text2 <> "" And Combo2 <> "" And Combo1 <> "" And Text7 <> "" And Text3 <> "" And Text4 <> "" And Text5 <> "" And Combo4 <> "" And Combo3 <> "") Then
If (IsDate(Text7)) Then
Conexion.Execute CadenaSql
MsgBox "El dato fue guardado correctamente."
txtcodigo.Text = ""
TxtApellidos.Text = ""
TxtNombres.Text = ""
TxtFechaNacimiento = ""
txtcodigo.SetFocus
Else
MsgBox "La fecha ingresada no es valida."
End If
Else
MsgBox "Uno o mas campos estan vacios"
End If
If Conexion.State = adStateOpen Then
Conexion.Close
End If
ControlError:
If Conexion.State = adStateOpen Then <<<<ACA ME SALE EL ERROR
Conexion.Close
End If
Select Case Err.Number
Case -2147467259
MsgBox "Ese dato se encuentra repetido"
End Select
End Sub
Espero que me puedan ayudar se los agradecería muchísimo!
Gracias
elcodigo es el siguiente:
Private Sub Command5_Click()
On Error GoTo ControlError:
Conexion.Open CadenaConexion
CadenaSql = "Insert Into Personal(codigo,Nombres,Apellido,DocdeIdentidad,Tipo,Edad,FechadeNacimiento,Domicilio,Telefono,E-Mail,Taller,Categoria) " & _
"Values(" & Text8 & ",'" & Text1 & "','" & _
Text6 & "','" & Text2 & "','" & _
Combo2 & "','" & Combo1 & "','" & _
Text7 & "','" & Text3 & "','" & _
Text4 & "','" & Text5 & "','" & _
Combo4 & "','" & Combo3 & "')"
If (Text8 <> "" And Text1 <> "" And Text6 <> "" And Text2 <> "" And Combo2 <> "" And Combo1 <> "" And Text7 <> "" And Text3 <> "" And Text4 <> "" And Text5 <> "" And Combo4 <> "" And Combo3 <> "") Then
If (IsDate(Text7)) Then
Conexion.Execute CadenaSql
MsgBox "El dato fue guardado correctamente."
txtcodigo.Text = ""
TxtApellidos.Text = ""
TxtNombres.Text = ""
TxtFechaNacimiento = ""
txtcodigo.SetFocus
Else
MsgBox "La fecha ingresada no es valida."
End If
Else
MsgBox "Uno o mas campos estan vacios"
End If
If Conexion.State = adStateOpen Then
Conexion.Close
End If
ControlError:
If Conexion.State = adStateOpen Then <<<<ACA ME SALE EL ERROR
Conexion.Close
End If
Select Case Err.Number
Case -2147467259
MsgBox "Ese dato se encuentra repetido"
End Select
End Sub
Espero que me puedan ayudar se los agradecería muchísimo!
Gracias
1 Respuesta
Respuesta de santiagomf