Form won't show newly entered record

  • Thread starter Thread starter Andre Beier
  • Start date Start date
A

Andre Beier

I have a form that displays ALL the records from one table continuosly. On
that form I have a button to create a new entry in a different form. When
the User clicks the SAVE Button of the new Form, I save the record and close
that form.

However, the NEW Record does not show up in my LIST. I always have to close
the form and reopen it.
I also tried to put an UPDATE Form-Button in there, but that does not seem
to have an impact at all.

So is closing out the form programmatically and open it again my only
option?

Thanks in advance

Andre
 
Andre,

You can use a requery statement in the CloseButton_OnClick event:

DoCmd.Close ' close the form
' check to see if the form is open
If fIsLoaded("frmOrderQuery") Then
[Forms]![frmOrderQuery].Requery
End If

However, the user will lose their place on the form and it will put the
cursor on the first record. This can be a pain in the neck. I use a function
like the following and call it after closing the form. For the function
"fIsLoaded" check out :
http://www.mvps.org/access/forms/frm0002.htm


Public Sub RefreshOrderQueryForm()

Dim lngOrdNum As Long, strCriteria As String
Const DummyString = "XXXX"
strCriteria = DummyString
If fIsLoaded("frmOrderQuery") Then
If IsNumeric([Forms]![frmOrderQuery].ORDER) Then
lngOrdNum = CLng([Forms]![frmOrderQuery].ORDER)
strCriteria = "[order] = " & lngOrdNum
End If
[Forms]![frmOrderQuery].Requery

' now put the cursor back to where it was

If strCriteria <> DummyString Then
[Forms]![frmOrderQuery].RecordsetClone.FindFirst strCriteria
If Not [Forms]![frmOrderQuery].RecordsetClone.NoMatch Then
[Forms]![frmOrderQuery].Bookmark =
[Forms]![frmOrderQuery].RecordsetClone.Bookmark
End If
End If
DoCmd.Maximize
End If
End Sub
 
Back
Top