You also need to force the forms recordset to update so that the new
record is available.
Forms!MainFormName.Requery
If you do that you will lose the record that is the current record.
So you may want to do something along the lines of the following when
you close the add form. WARNING: Untested code follows.
Dim strCurrentName as String
With Forms![MainFormName]
strCurrentName = .[FullName]
.Requery
.RecordSetClone.FindFirst "[FullName] = """ & strCurrentName & """"
If RecordsetClone.NoMatch = False then
.Bookmark = RecordsetClone.Bookmark
else
Msgbox "Can't find " & strCurrentName & "!",,"Whoops!"
End IF
End With
Sorry gotta go, grandkids at the door.
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
thanks. It shows in comb box. However, I cannot go to newly added
record until after I close and reopen main form. Here is the code:
Private Sub cboFind_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[FullName] = """ & Me![cboFind] & """"
Me.Bookmark = rs.Bookmark
Me.cmdClose.SetFocus
End Sub
In the Close event of your add form, put this code (substituting
your actual
form and combo box name)
[Forms]![MainFormName]![SearchComboBoxName].Requery
:
I have main form with a combo box to search name and add form to
add record.
After adding record and close add form, newly added record does not
show in
search combo box of main form. I have to close the main form and
re-open it
to show the newly added record in the search combo box. How to fix it?
Thanks.