I have created custom navigation buttons and Record Number indicators on several forms that are used to review and update records based on a query.
My On Current event to update the "Record X of Y" is
This works as it should when using the custom navigation buttons, which I use to force the user to confirm the desire to save the record if changes have been made, and then to re-query the table, thereby no longer showing the records that have been 'finalized' based on certain fields being pouplated, and then return to the next record that would have been displayed or, if at the last record, go to the first record. To accomplish this, I have the following as part of my On Click event:
As i mentioned, I have similar functions on several forms, but for some reason only 1 of them is not working properly after the code above is executed. On the forms working correctly, if you were originally on record 4 of 10, and the changes you made now 'finalized' the record, after the requery the Record indicated will display Record 4 of 9 (or 3 of 9 if you used the Previous Record button, which has similar code).
On the form that isn't working, if you were on Record 4 of 10 and updated the record, after the requery it would state Record 4 of 4 (or 3 of 3 w/ previous). Navigating to another record will then cause the box to update correctly, i.e. Record 5 of 9 when you go to next.
The code is the same on all of the forms. The Enabled and Locked properties are set to Yes on all forms.
Does anyone have any idea what else I should check to determine why one of the forms in not updating properly when the others are?
Thanks in advance for your help!
My On Current event to update the "Record X of Y" is
Code:
Private Sub Form_Current()
Dim frm As Form, LastRec As Long
Set frm = Forms!ReviewSearchRecordsForm
If Trim(frm!txtRecordNo & "") = "" Then
Me.RecordsetClone.MoveLast
DoEvents
End If
LastRec = Me.RecordsetClone.RecordCount
If Me.NewRecord Then LastRec = LastRec + 1
frm!txtRecordNo = "Record " & CStr(Me.CurrentRecord) & " of " & CStr(LastRec)
Set frm = Nothing
End Sub
Code:
With Recordset If .AbsolutePosition = .RecordCount - 1 Then DoCmd.GoToRecord , , acFirst Else DoCmd.GoToRecord , , acNext End If End With Dim CurrentKey As Integer CurrentKey = [ID] Me.Requery Me.Recordset.FindFirst "[Id] = " & CurrentKey
On the form that isn't working, if you were on Record 4 of 10 and updated the record, after the requery it would state Record 4 of 4 (or 3 of 3 w/ previous). Navigating to another record will then cause the box to update correctly, i.e. Record 5 of 9 when you go to next.
The code is the same on all of the forms. The Enabled and Locked properties are set to Yes on all forms.
Does anyone have any idea what else I should check to determine why one of the forms in not updating properly when the others are?
Thanks in advance for your help!
Comment