G
Guest
Hello. Ill try to outline the structure of my form first
Tables:
T_Names, includes fields: Stud_ID, Stud_Nam
T_Car, includes fields: Stud_ID, Licence No., Make, Model, et
I have a main form with a subform within it. The main form basically consists of an unbound combo box which searches for Stud_Name from the T_Names table, and i have an After Update function which generates the corresponding Stud_ID record for that Stud_Name in a text box called Stud_ID in the main form, and also brings up that record in the subform. The purpose of the subform is to update data in the T_Car table. My code for the AfterUpdate function is (the name of the Stud_Name combo box is Combo17)
Private Sub Combo17_AfterUpdate(
' Find the record that matches the control
Dim rs As Objec
Set rs = Me.Recordset.Clon
rs.FindFirst "[Stud_ID] = '" & Me![Combo17] & "'
If Not rs.EOF Then Me.Bookmark = rs.Bookmar
End Su
Sometimes it is necessary to add data to a record that is not found in the Stud_Names field, so i have created a function that allows the user to update the T_Names table when they double click the combo box. Here is the code for that
Private Sub Combo17_DblClick(Cancel As Integer
Dim LinkCriteria As Strin
LinkCriteria = "[Stud_Name] = '" & Me!Combo17.Text & "'
DoCmd.OpenForm "F_MaintainNames", , , LinkCriteri
End Su
The afterupdate function works fine when a name is selected from the list. The doubleclick function also works well in adding the name to the T_Names table and the combo box, but the original after update function (the one that would populate the text box in the main field and the subform) doesn't work when i select the newly added name from the combo box. I have noticed that if i exit the form and reenter it and look up the name that i just added it works fine. What is the missing code to make the afterupdate work once i have selected the newly added name from the combo box and where does it go? Am i right in thinking along 'requery' lines?
Thanks for spending the time reading and hope a speedy answer is on its way!
Tables:
T_Names, includes fields: Stud_ID, Stud_Nam
T_Car, includes fields: Stud_ID, Licence No., Make, Model, et
I have a main form with a subform within it. The main form basically consists of an unbound combo box which searches for Stud_Name from the T_Names table, and i have an After Update function which generates the corresponding Stud_ID record for that Stud_Name in a text box called Stud_ID in the main form, and also brings up that record in the subform. The purpose of the subform is to update data in the T_Car table. My code for the AfterUpdate function is (the name of the Stud_Name combo box is Combo17)
Private Sub Combo17_AfterUpdate(
' Find the record that matches the control
Dim rs As Objec
Set rs = Me.Recordset.Clon
rs.FindFirst "[Stud_ID] = '" & Me![Combo17] & "'
If Not rs.EOF Then Me.Bookmark = rs.Bookmar
End Su
Sometimes it is necessary to add data to a record that is not found in the Stud_Names field, so i have created a function that allows the user to update the T_Names table when they double click the combo box. Here is the code for that
Private Sub Combo17_DblClick(Cancel As Integer
Dim LinkCriteria As Strin
LinkCriteria = "[Stud_Name] = '" & Me!Combo17.Text & "'
DoCmd.OpenForm "F_MaintainNames", , , LinkCriteri
End Su
The afterupdate function works fine when a name is selected from the list. The doubleclick function also works well in adding the name to the T_Names table and the combo box, but the original after update function (the one that would populate the text box in the main field and the subform) doesn't work when i select the newly added name from the combo box. I have noticed that if i exit the form and reenter it and look up the name that i just added it works fine. What is the missing code to make the afterupdate work once i have selected the newly added name from the combo box and where does it go? Am i right in thinking along 'requery' lines?
Thanks for spending the time reading and hope a speedy answer is on its way!