RE:Voy a llorar !!!!!! y me van a correr =(
ESTO AGREGA CAMPOS A UNA BD ACCESS, OJO CON LAS COMILLAS, VAN EN ORDEN EJEMOLO:, TEXT3 SE GRABARA EN EL CAMPO N°1, ASI SUCESIVAMENTE
private Sub Command1_Click()
sql = Empty
On Error GoTo Control
If MsgBox("¿Agregar Nuevo Funcionario?", vbYesNo + vbQuestion, "Grabar") = vbYes Then (misma linea de arriba)
sql = " insert into empleados "
sql = sql + " values ('" & Text3.Text & "','" & Text1.Text & "','" & Text2.Text & "',"
sql = sql + "'" & Combo1.Text & "','" & Text7.Text & "','" & Text8.Text & "','" & Text9.Text & "'," (misma linea de arriba)
sql = sql + "'" & Text5.Text & "','" & Text6.Text & "','" & Text10.Text & "',"
sql = sql + "'" & DTPicker2 & "','" & DTPicker3 & "',"
sql = sql + "'" & DTPicker4 & "','" & DTPicker1 & "')"
db.Execute sql, dbFailOnError
Control:
If Err.Number > 0 Then
MsgBox Err.Description, vbExclamation, "Mensaje"
Exit Sub
End If
ESTE OTRO CODIGO ES PARA MODIFICAR DATOS EN LA BASE DE DATOS ACCES"OJO CON LAS COMILLAS, SI UNA LINEA DE MODIFICACION NO EMPIEZA CON SQL =, ENTONCES ES DE LA LIENEA DE ARRIBA
Private Sub Command1_Click()
sql = ""
sql = "select * from empleados(NOMBRE DE TABLA)"
sql = sql + " where rut_emple= '" & Text2.Text & "'"
Command1.Caption = "&GRABAR&"
If Command1.Caption = "&GRABAR&" Then
sql = Empty
sql = "select * from empleados where rut_emple = '" & Text2.Text & "'"
Set rs = db.OpenRecordset(sql, 2)
If rs.RecordCount > 0 Then
If MsgBox("¿Desea Grabar los cambios?", vbYesNo + vbQuestion, "Modificar") = vbYes Then
On Error GoTo Control
sql = Empty
sql = " update empleados set nombre_emple = '" & Text1.Text & "',"
sql = sql + " ficha = '" & Text3.Text & "',"
sql = sql + " dias_vaca = '" & Text4.Text & "', dias_acumu = '" & Text5.Text & "',"
sql = sql + " dias_de_uso = '" & Text6.Text & "', t_dias = '" & Text7.Text & "',"
sql = sql + " dias_admi = '" & Text8.Text & "', dias_admi_usa = '" & Text8.Text & "',"
sql = sql + " total_dias_admi = '" & Text10.Text & "', fecha_inicio_vaca = '" & DTPicker2 & "',"
sql = sql + " fecha_termino_vaca = '" & DTPicker3 & "', fecha_ultimo_dia_admi = '" & DTPicker4 & "',"
sql = sql + " fecha_incorporacion = '" & DTPicker1 & "'"
sql = sql + " where rut_emple = '" & Text2.Text & "'"
db.Execute sql, dbFailOnError
Control:
If Err.Number > 0 Then
MsgBox Err.Description, vbExclamation, "Mensaje"
Exit Sub
End If