J
John C.
I have a form which allows the user to add new records (by
use of the navigation button).
The form record source is a query which sorts the data by
last name, ascending.
When adding a new record, I want the form to retain proper
sort order. I have noticed that the added record remains
as the last record until the form is closed and re-opened.
I have tried .refresh, but that does not effect the sort
order.
I am trying to use .requery, which does place everything
in proper sort order, but will return to the first record
unless I 'trap' the current records [autonumm] value.
Then use this as criteria to return to.
Here's what I have, I need help determining the current
records [AutoNum] field value that is not displayed on the
form.
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Test to see if record being updated is a new record
varNewRecord = Me.NewRecord
If varNewRecord = True Then
varAutoNum = ***not sure how to lookup***
End If
End Sub
Private Sub Form_AfterUpdate()
'If record being updated was a new record
If varNewRecord = True Then
Me.Requery
With Me.RecordsetClone
.MoveFirst
.FindFirst "[AutoNum] = '" & varAutoNum & "'"
Me.Recordset.Bookmark = .Bookmark
End With
End If
End Sub
use of the navigation button).
The form record source is a query which sorts the data by
last name, ascending.
When adding a new record, I want the form to retain proper
sort order. I have noticed that the added record remains
as the last record until the form is closed and re-opened.
I have tried .refresh, but that does not effect the sort
order.
I am trying to use .requery, which does place everything
in proper sort order, but will return to the first record
unless I 'trap' the current records [autonumm] value.
Then use this as criteria to return to.
Here's what I have, I need help determining the current
records [AutoNum] field value that is not displayed on the
form.
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Test to see if record being updated is a new record
varNewRecord = Me.NewRecord
If varNewRecord = True Then
varAutoNum = ***not sure how to lookup***
End If
End Sub
Private Sub Form_AfterUpdate()
'If record being updated was a new record
If varNewRecord = True Then
Me.Requery
With Me.RecordsetClone
.MoveFirst
.FindFirst "[AutoNum] = '" & varAutoNum & "'"
Me.Recordset.Bookmark = .Bookmark
End With
End If
End Sub