Undo changes in sub form (1 Viewer)

mercystone

Member
Local time
Today, 20:03
Joined
Sep 20, 2021
Messages
108
I have a main form and a subform from 2 tables. How can i remove a field from sub form without deleting from a table?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 18:03
Joined
Feb 19, 2013
Messages
14,218
delete the control

edit: if your subform control has a table as its source object (not a good idea) then best you can do is hide the column (right click on the header), but other users can unhide it again
 

mercystone

Member
Local time
Today, 20:03
Joined
Sep 20, 2021
Messages
108
delete the control

edit: if your subform control has a table as its source object (not a good idea) then best you can do is hide the column (right click on the header), but other users can unhide it again
Kindly have a look at this database and look Students examination details. I want to undo changes saved.
 

Attachments

  • STUDENTS (2).zip
    85.6 KB · Views: 34

CJ_London

Super Moderator
Staff member
Local time
Today, 18:03
Joined
Feb 19, 2013
Messages
14,218
I've had has a quick look and think what you mean is to hide the row

if that is the case use this code in the mark afterupdate event

Code:
Private Sub Mark_AfterUpdate()
Static s As String


    s = "," & Me.ID & s
    Me.Filter = "ID NOT IN (" & Mid(s, 2) & ")"
    Me.FilterOn = True
   
End Sub

those records should remain hidden for the period of the session - they will reappear when the form is reopened
 

mercystone

Member
Local time
Today, 20:03
Joined
Sep 20, 2021
Messages
108
I've had has a quick look and think what you mean is to hide the row

if that is the case use this code in the mark afterupdate event

Code:
Private Sub Mark_AfterUpdate()
Static s As String


    s = "," & Me.ID & s
    Me.Filter = "ID NOT IN (" & Mid(s, 2) & ")"
    Me.FilterOn = True
   
End Sub

those records should remain hidden for the period of the session - they will reappear when the form is reopened
Thanks. What if I had saved the subject for the Student and this Student drops a subject at some point, will the same code apply?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 18:03
Joined
Feb 19, 2013
Messages
14,218
I don't understand how your app is supposed to work, but I wouldn't think so, you would need something in your tables that your query can filter on to remove it (perhaps a date when the student dropped the subject - dates are better than tickboxes because they tell you when which is often more useful)
 

mercystone

Member
Local time
Today, 20:03
Joined
Sep 20, 2021
Messages
108
Kindly assist me us
I don't understand how your app is supposed to work, but I wouldn't think so, you would need something in your tables that your query can filter on to remove it (perhaps a date when the student dropped the subject - dates are better than tickboxes because they tell you when which is often more useful)
Ing
I don't understand how your app is supposed to work, but I wouldn't think so, you would need something in your tables that your query can filter on to remove it (perhaps a date when the student dropped the subject - dates are better than tickboxes because they tell you when which is often more useful)
Kindly assist me by using the attached database on how to go about it
 

Attachments

  • STUDENTS (2).zip
    85.6 KB · Views: 39

CJ_London

Super Moderator
Staff member
Local time
Today, 18:03
Joined
Feb 19, 2013
Messages
14,218
include a field called DateDropped in your studentsubjects table

modify your subform recordsource to include the criteria

WHERE DateDropped is null

Up to you how and when you populate the new field, might need a new form, might include it in your current subform - in which case you would need to modify the code I provided to

Me.Filter = "ID NOT IN (" & Mid(s, 2) & ") AND DateDropped is not null"
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:03
Joined
Feb 19, 2002
Messages
35,914
We don't recommend deleting records once they are created but sometimes you want to do it with rules and xo CJ is explaining how you can leave the data in the database but just not see it on the form.

I think in this case, deleting wouldn't be awful so if you want to actually delete the row, you need to add a delete button to the right of marks to give the user some way to tell you that he wants to delete a subject.

Looking at what you have, there seems to be a missing table. The only time, the Subject would have a marks field is if there was only ever ONE mark entered for the entire course. Usually there are other marks that get entered and the sum/avg of all the marks ends up being the ending grade for the class. So I think you need a fourth table -- StudentSubjectMarks

The FK will be StudentSubhectsID (it is really poor practice to name all your PKs ID. It just makes the relationships impossible to identify unless you have a relationship diagram open in front of you.) Then you need TestDate, TestType, and the Mark. Having a type field allows the teachere to look at exams separately from weekly tests or special projects. It's a nice touch for flexiblity
 

mercystone

Member
Local time
Today, 20:03
Joined
Sep 20, 2021
Messages
108
We don't recommend deleting records once they are created but sometimes you want to do it with rules and xo CJ is explaining how you can leave the data in the database but just not see it on the form.

I think in this case, deleting wouldn't be awful so if you want to actually delete the row, you need to add a delete button to the right of marks to give the user some way to tell you that he wants to delete a subject.

Looking at what you have, there seems to be a missing table. The only time, the Subject would have a marks field is if there was only ever ONE mark entered for the entire course. Usually there are other marks that get entered and the sum/avg of all the marks ends up being the ending grade for the class. So I think you need a fourth table -- StudentSubjectMarks

The FK will be StudentSubhectsID (it is really poor practice to name all your PKs ID. It just makes the relationships impossible to identify unless you have a relationship diagram open in front of you.) Then you need TestDate, TestType, and the Mark. Having a type field allows the teachere to look at exams separately from weekly tests or special projects. It's a nice touch for flexiblity
Good input. Actually I was having an impression that it will be hard to refer to last term's results. I tried using:
=DlookUp("[Total Marks]","qryGrades","[ID]="&[ID]-1)
But it gives me minus the testdate. I think your suggestion for a fourth table will be very effective.
 

mercystone

Member
Local time
Today, 20:03
Joined
Sep 20, 2021
Messages
108
Good input. Actually I was having an impression that it will be hard to refer to last term's results. I tried using:
=DlookUp("[Total Marks]","qryGrades","[ID]="&[ID]-1)
But it gives me minus the testdate. I think your suggestion for a fourth table will be very effective.
Or is there any other way to refer to last term results if:
Term 1:- January, February, march and April
Term 2:- May, June, July and August
Term 3:- September, October, November and December.
I might to refer to last term results
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:03
Joined
Feb 19, 2002
Messages
35,914
I didn't notice term in your table so you might want to post the current version. Also term doesn't stand alone anyway. You need SchoolYear AND Term. Add two combos to the form. These are going to be cascading combos. The first will select year and the second will be filtered by year and select term. You can refer to these combos in your RecordSource query OR in the where argument if you are using OpenReport or OpenForm.
 

mercystone

Member
Local time
Today, 20:03
Joined
Sep 20, 2021
Messages
108
I have a main form and a subform from 2 tables. How can i remove a field from sub form without deleting from a table?
I didn't notice term in your table so you might want to post the current version. Also term doesn't stand alone anyway. You need SchoolYear AND Term. Add two combos to the form. These are going to be cascading combos. The first will select year and the second will be filtered by year and select term. You can refer to these combos in your RecordSource query OR in the where argument if you are using OpenReport or OpenForm.
To get the term i am using this

="TERM " & ((Month(Date()-1\4)+1

And to get the year i am using this

=Format(Now(), "yyyy")

But I am considering your approach. Any input will be highly appreciated.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:03
Joined
Feb 19, 2002
Messages
35,914
That is fine for when you save the data. I was talking about searching for existing data.
 

Cronk

Registered User.
Local time
Tomorrow, 03:03
Joined
Jul 4, 2013
Messages
2,660
You need extra fields in StudentSubjects to record Year and Term to record for any student, subjects for different terms and different years.
 

mercystone

Member
Local time
Today, 20:03
Joined
Sep 20, 2021
Messages
108
You need extra fields in StudentSubjects to record Year and Term to record for any student, subjects for different terms and different years.
Kindly use the attached database and assist me by updating
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:03
Joined
Feb 19, 2002
Messages
35,914
Kindly use the attached database and assist me by updating
Kindly try to implement the instructions yourself. We are happy to advise but you have to at least put some effort into the process.
 

Cronk

Registered User.
Local time
Tomorrow, 03:03
Joined
Jul 4, 2013
Messages
2,660
:)

What chances this is a school assignment?
 

Users who are viewing this thread

Top Bottom