Ayuda base de datos con ado y access en visual basic
El erro me dice que no coinciden los tipos de datos en la expresión de criterios \
Específicamente en el case AGREGAR_REGISTRO es donde me marca el error \
En el case EDITAR_REGISTRO esta todo perfecto de antemano gracias \
_____________________________________________________________\
Private Sub cmdGuardar_Click()
On Error GoTo ErrorSub
' Valida el Nombre que no este vacío
''''''''''''''''''''''''''''''''
If Trim(Text1(1)) = "" Then
MsgBox "El Nombre de registro no puede estar vacio", vbCritical, "Datos incompletos"
Text1(1).SetFocus
Exit Sub
' Valida el Apellido
''''''''''''''''''''''''''''''''
ElseIf Trim(Text1(2)) = "" Then
MsgBox "El Apellido no puede estar vacio", vbCritical, "Datos incompletos"
Text1(2).SetFocus
Exit Sub
' Valida el Sexo
''''''''''''''''''''''''''''''''
ElseIf Trim(CmbSexo.Text) = "" Then
MsgBox "No se ha indicado el Afiliación", vbCritical, "Datos incompletos"
CmbSexo.SetFocus
Exit Sub
End If
'Agrega el registro
'''''''''''''''''''''''''''''''
Select Case ACCION
Case EDITAR_REGISTRO
cnn.Execute "UPDATE Personas set Nombre = '" & Text1(1) & _
"', Apellido = '" & Text1(2) & _
"', Telefono = '" & Text1(3) & _
"', Direccion = '" & Text1(4) & _
"', Canacope = '" & CmbSexo.ListIndex & _
"', A2008 = '" & a1 & _
"', A2009 = '" & a2 & _
"', A2010 = '" & a3 & _
"', A2011 = '" & a4 & _
"' where Id = " & IdRegistro & ""
Case AGREGAR_REGISTRO
cnn.Execute "INSERT INTO Personas " & "(Nombre,Apellido,Telefono,Direccion,Canacope,FechaDeAlta,A2008,A2009,A2010,A2011) VALUES('" & _
Text1(1) & "','" & _
Text1(2) & "','" & _
Text1(3) & "','" & _
Text1(4) & "','" & _
CmbSexo.ListIndex & "','" & _
Check1 & "','" & _
Check2 & "','" & _
Check3 & "','" & _
Check4 & "','" & _
Format(Date, "dd/mm/yyyy") & "')"
End Select
rs.Requery
Call CargarListView(FrmPrincipal.LV, rs)
DoEvents
Unload Me
Set FrmEdit = Nothing
Exit Sub
ErrorSub:
MsgBox Err.Description
End...
Específicamente en el case AGREGAR_REGISTRO es donde me marca el error \
En el case EDITAR_REGISTRO esta todo perfecto de antemano gracias \
_____________________________________________________________\
Private Sub cmdGuardar_Click()
On Error GoTo ErrorSub
' Valida el Nombre que no este vacío
''''''''''''''''''''''''''''''''
If Trim(Text1(1)) = "" Then
MsgBox "El Nombre de registro no puede estar vacio", vbCritical, "Datos incompletos"
Text1(1).SetFocus
Exit Sub
' Valida el Apellido
''''''''''''''''''''''''''''''''
ElseIf Trim(Text1(2)) = "" Then
MsgBox "El Apellido no puede estar vacio", vbCritical, "Datos incompletos"
Text1(2).SetFocus
Exit Sub
' Valida el Sexo
''''''''''''''''''''''''''''''''
ElseIf Trim(CmbSexo.Text) = "" Then
MsgBox "No se ha indicado el Afiliación", vbCritical, "Datos incompletos"
CmbSexo.SetFocus
Exit Sub
End If
'Agrega el registro
'''''''''''''''''''''''''''''''
Select Case ACCION
Case EDITAR_REGISTRO
cnn.Execute "UPDATE Personas set Nombre = '" & Text1(1) & _
"', Apellido = '" & Text1(2) & _
"', Telefono = '" & Text1(3) & _
"', Direccion = '" & Text1(4) & _
"', Canacope = '" & CmbSexo.ListIndex & _
"', A2008 = '" & a1 & _
"', A2009 = '" & a2 & _
"', A2010 = '" & a3 & _
"', A2011 = '" & a4 & _
"' where Id = " & IdRegistro & ""
Case AGREGAR_REGISTRO
cnn.Execute "INSERT INTO Personas " & "(Nombre,Apellido,Telefono,Direccion,Canacope,FechaDeAlta,A2008,A2009,A2010,A2011) VALUES('" & _
Text1(1) & "','" & _
Text1(2) & "','" & _
Text1(3) & "','" & _
Text1(4) & "','" & _
CmbSexo.ListIndex & "','" & _
Check1 & "','" & _
Check2 & "','" & _
Check3 & "','" & _
Check4 & "','" & _
Format(Date, "dd/mm/yyyy") & "')"
End Select
rs.Requery
Call CargarListView(FrmPrincipal.LV, rs)
DoEvents
Unload Me
Set FrmEdit = Nothing
Exit Sub
ErrorSub:
MsgBox Err.Description
End...
1 Respuesta
Respuesta de Roberto Alvarado
1