Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display details of new record after adding one to the combo box

Status
Not open for further replies.

chrislx

Programmer
Oct 17, 2003
32
US
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

 
Have you tried to replace this:
If Not rs.EOF Then Forms![Form-1].Bookmark = rs.Bookmark
by this ?
If Not rs.[highlight]NoMatch[/highlight] Then Forms![Form-1].Bookmark = rs.Bookmark

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top