DoCmd.RunCommand acCmdDeleteRecord de distintas tablas en simultaneo
Tengo la fórmula que detallo abajo, funciona bien salvo porque la instrucción delete record solo me borra el registro actual en el formulario actual (en la tabla Paciente). Como verán hay otras tablas involucradas (Evolución e HC_Ingreso) y quisiera que también borre el registro de esas tablas. ¿Cómo se especifica el registro a borrar? Lo que identifica a cada registro es el DNI (tipo texto).
Private Sub cmdAlta_Click()
If MsgBox("¿Desea dar egreso a este paciente?", vbYesNo, "Gestion de pacientes JANIES") = vbYes Then
If IsNull(Me.F_Nacimiento) Then
CurrentDb.Execute "INSERT INTO Historial_Paciente (DNI, Nombre_Apellido, Cama, Edad, F_Ingreso, Diagnostico, Obra_Social, Derivado, Tel_Contacto, F_Egreso) VALUES ('" & Me.DNI & "','" & Me.Nombre_Apellido & "'," & Me.Cama & ",'" & Me.Edad & "',#" & Format(Me.F_Ingreso, "mm/dd/yyyy") & "#,'" & Me.Diagnostico & "','" & Me.Obra_Social & "','" & Me.Derivado & "','" & Me.Tel_Contacto & "',#" & Format(Me.F_Egreso, "mm/dd/yyyy") & "#)"
Else
CurrentDb.Execute "INSERT INTO Historial_Paciente (DNI, Nombre_Apellido, Cama, F_Nacimiento, Edad, F_Ingreso, Diagnostico, Obra_Social, Derivado, Tel_Contacto, F_Egreso) VALUES ('" & Me.DNI & "','" & Me.Nombre_Apellido & "'," & Me.Cama & ",#" & Format(Me.F_Nacimiento, "mm/dd/yyyy") & "#,'" & Me.Edad & "',#" & Format(Me.F_Ingreso, "mm/dd/yyyy") & "#,'" & Me.Diagnostico & "','" & Me.Obra_Social & "','" & Me.Derivado & "','" & Me.Tel_Contacto & "',#" & Format(Me.F_Egreso, "mm/dd/yyyy") & "#)"
End If
If MsgBox("¿Desea tambien archivar las evoluciones e historia clinica del paciente?", vbYesNo, "Gestion de pacientes JANIES") = vbYes Then
CurrentDb.Execute "INSERT INTO Historial_Evolucion SELECT * FROM Evolucion WHERE DNI = '" & Me.DNI & "'"
CurrentDb.Execute "INSERT INTO Historial_HC_Ingreso SELECT * FROM HC_Ingreso WHERE DNI = '" & Me.DNI & "'"
End If
DoCmd.SetWarnings False
AllowEdits = True
DoCmd.RunCommand acCmdDeleteRecord
Me.Requery
DoCmd.SetWarnings True
AllowEdits = False
End If
End Sub
2 respuestas
Respuesta
1
Respuesta de fichu
1

