Solved Afterupdate code error to update data from Child form to Parent form (1 Viewer)

ZKHADI

Member
Local time
Today, 20:30
Joined
Apr 5, 2021
Messages
86
hy buddies!

see below there is an image

Parent Form = StudentRecord
Parent textbox = CurrentFacultySemester

ChildForm = FeeFormSheet
Childform Combobox = Faculty

i applied the afterupdate event on childform / Faculty combobox to add new fee and faculty for a student. when a student reading in current semester which i issued a receipt to him that i need in the Parent form's text box which is existing field in the form's table. i need the current faculty for each student.
i wrote the code but it didnt work i think there is an error.

Update text box on Parentform from Childform

kindly resolve the code.
 

Attachments

  • Untitled.png
    Untitled.png
    292.3 KB · Views: 54

June7

AWF VIP
Local time
Today, 07:30
Joined
Mar 9, 2014
Messages
4,450
Post code as text, not image. Use the CODE icon on toolbar.

Current faculty for each student should be calculated when needed, not saved to parent table.

If code is behind subform and you want to save data to parent form, why does code try to set value of control in subform? Try:

Me.Parent.CurrentFacultySemester = Me.Faculty.Column(1)
 

ZKHADI

Member
Local time
Today, 20:30
Joined
Apr 5, 2021
Messages
86
Post code as text, not image. Use the CODE icon on toolbar.

Current faculty for each student should be calculated when needed, not saved to parent table.

If code is behind subform and you want to save data to parent form, why does code try to set value of control in subform? Try:

Me.Parent.CurrentFacultySemester = Me.Faculty.Column(1)
thank you it worked.....
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:30
Joined
Feb 19, 2002
Messages
36,868
Me.Parent.CurrentFacultySemester = Me.Faculty.Column(1)
As has been mentioned, this is poor practice in general but actually wrong in this instance since you would Never copy the text string, you would copy the ID so the expression would be:

Me.Parent.CurrentFacultySemester = Me.Faculty --- assuming the bound ID is the first field.

Normally, the first field in the combo's RowSource is the bound field. Then you use 0" as the length to hide it. If you built the combo yourself and ordered the RowSource as textvalue, UniqueID, then the bound column would be 2 but would be referred to as you have as .Column(1) because the Column property is a zero based array so .Column(0) is the first column and .Column(1) is the second column.
 

Users who are viewing this thread

Top Bottom