I have trouble to find out a solution on the following, Please help.
1. Form-1 includes Combo box, Text fields, subforms and buttons (Create, Delete)
2. After selecting a key code from the combo box ([Form-1].[Input-Name]), display the details in TextFields (table-1) and subforms (other tables).
3. If clicking on button Create, Form-2 is opened. Form-2 includes text fields (which are bounded to the table-1) and button Close
4. After button Close is clicked, there are 2 things which should be done:
a. Close Form-2
b. Display the newly created record on the textfield of Form-1 and there shouldn't been any data in the subforms
Problem:
After closing Form-2, Form-1 controls still display the old record which is shown before the creation, though the new record is in the list if I click the combo box
My code as following:
‘When button Close on Form-2 is clicked
Private Sub newClsClose_Click()
Forms![Form-1].Requery
Forms![Form-1].[Input-Name].Requery 'combo box requery
'Find the record that matches the control
Dim rs As DAO.Recordset
Set rs = Forms![Form-1].Recordset.Clone
rs.FindFirst "[Class-Name] = '" & Me.Input_Name & "'"
If Not rs.EOF Then Forms![Form-1].Bookmark = rs.Bookmark
Forms![Form-1]![Input-Name].Value = Me!Input_Name
DoCmd.Close
End Sub
I can see the new one in the combo box, guess that it is because .requery works. Why the recordset.Clone and .Bookmark do not work?
Thanks again
Chrislx
1. Form-1 includes Combo box, Text fields, subforms and buttons (Create, Delete)
2. After selecting a key code from the combo box ([Form-1].[Input-Name]), display the details in TextFields (table-1) and subforms (other tables).
3. If clicking on button Create, Form-2 is opened. Form-2 includes text fields (which are bounded to the table-1) and button Close
4. After button Close is clicked, there are 2 things which should be done:
a. Close Form-2
b. Display the newly created record on the textfield of Form-1 and there shouldn't been any data in the subforms
Problem:
After closing Form-2, Form-1 controls still display the old record which is shown before the creation, though the new record is in the list if I click the combo box
My code as following:
‘When button Close on Form-2 is clicked
Private Sub newClsClose_Click()
Forms![Form-1].Requery
Forms![Form-1].[Input-Name].Requery 'combo box requery
'Find the record that matches the control
Dim rs As DAO.Recordset
Set rs = Forms![Form-1].Recordset.Clone
rs.FindFirst "[Class-Name] = '" & Me.Input_Name & "'"
If Not rs.EOF Then Forms![Form-1].Bookmark = rs.Bookmark
Forms![Form-1]![Input-Name].Value = Me!Input_Name
DoCmd.Close
End Sub
I can see the new one in the combo box, guess that it is because .requery works. Why the recordset.Clone and .Bookmark do not work?
Thanks again
Chrislx