programmer67
New member
- Local time
- Today, 20:41
- Joined
- Jan 12, 2023
- Messages
- 4
Try this brother:hello bro,
i want to delete records from main form.
3 table relationship with "ogrenci_id"
when pres DELETE
1- ogrencitakip record will delete
2- borctakip record will delete
3- derstakip record will delete
i hope understand me
Thank you sir so much for that sir @ Pat Hartman it's my pleasure to know that since im still in the level of learning process. I just share which working on my part for the sake that he maybe get some possible solution but not absolute.Did you create relationships using the Relationship window? If you didn't, then do it now. Select the enforce RI checkbox. If you want the delete to cascade, then check Cascade Delete on both relationships. Then you delete ONE record. The top record in the relationship and the database engine takes care of the rest. The code posted by @Kamayo Ako won't work unless there is only ONE row at each level.
Thank you brother, really working now.Try this brother:
Private Sub cmdDelete_Click()
Dim lngID As Long
Dim lngID1 As Long
Dim lngID2 As Long
Dim strSQL As String
Dim strSQL1 As String
Dim strSQL2 As String
DoCmd.SetWarnings False
lngID = ogrenci_id.Value
lngID1 = ogrenci_id.Value
lngID2 = ogrenci_id.Value
DoCmd.runSQL "DELETE * FROM borctakip WHERE ogrenci_id= " & lngID
DoCmd.runSQL1 "DELETE * FROM derstakip WHERE ogrenci_id= " & lngID1
DoCmd.runSQL2 "DELETE * FROM ogrencitakip WHERE ogrenci_id= " & lngID2
Me.Requery
DoCmd.SetWarnings True
Else
End If
You welcome brother. But you must also consider the opinion of sir @ Pat Hartman since he had a great experience and expertise concerning that issue.Thank you brother, really working now.
Thank you brother,Did you create relationships using the Relationship window? If you didn't, then do it now. Select the enforce RI checkbox. If you want the delete to cascade, then check Cascade Delete on both relationships. Then you delete ONE record. The top record in the relationship and the database engine takes care of the rest. The code posted by @Kamayo Ako won't work unless there is only ONE row at each level.
As long as that particular table record has a FK that bind them with Main transaction table PK like ogrenci-id then you can do same process but add another declaration.Thank you brother,
i have one more table that "ogrenciler" mean students. I do relations In Relationship window. But ogrenciler.id -> borctakip.ogrenci_id, ogenciler.id -> derstakip.ogrenci_adi, ogrenciler.id -> ogrencitakip.ogrenci-id.
thank you brother but now i am not interested in classrooms.Be careful with this.
I suspect you wouldn't want to delete a student if their class was removed or a study class if one student was removed.
Generally speaking, you shouldn't delete records, but mark them as Archived and exclude them from your queries based on that flag being set, unless you have physically run out of space.
How would you handle historic reporting with no old data?
Compare attendance levels from year to year... etc. etc.
For the record (not that she cares), Pat is a woman. Shouldn't change anything as far as your interaction with her, but for some reason I feel compelled to make corrections when gender is incorrectly assumed.sir @ Pat Hartman
No, I have mentioned it myself in the past, and I sure as hell do not have the woke disease.You seem to have caught the woke disease![]()
They put it in my COVID "vaccination"...You seem to have caught the woke disease![]()