Private Sub tBlade_AfterUpdate()
Me.test.SetFocus
scanresults
DoCmd.GoToRecord , , acLast
If Me.CurrentRecord > 14 Then DoCmd.GoToRecord , , acPrevious, 14
End Sub
I do pretty much the same as you. I go to the end of the recordset of the query for the form, and then go back 5 records, as I have a emulated split form as a subform.
If I filter for a client and then inspect Me.CurrentRecord it shows the number of records as shown at the bottom of the form. If I remove the filter it does the same but for all the records returned by the query.
I do not know what error 2455 is and don't really want to have to go searching for what that error is.
So it would seem, this was all done on the assumption that the sub-form was the active form. I now have it working:
Code:
Me.test.SetFocus
testresults
DoCmd.GoToRecord , , acLast
If [test].Form.Recordset.RecordCount > 14 Then DoCmd.GoToRecord , , acPrevious, 14
Although this works, I think it shouldn't. Going to the last record should put it at the top of the form and you have to scroll up for earlier ones, to get it to the bottom of the form I moved it back 14.
Now I go to the last record and only move it back 14 if there are enough records and you would expect this to put the last record at the top if there were less than 15 records and you have to scroll up for the rest, it instead shows all the records (for example 4) as I want.
Now I go to the last record and only move it back 14 if there are enough records and you would expect this to put the last record at the top if there were less than 15 records and you have to scroll up for the rest, it instead shows all the records (for example 4) as I want.
Say you have a form with sufficient space for 15 records.
If you have 16 records a scroll bar appears (obviously)
Selecting the last record using the navigation buttons both moves the focus and changes the records displayed
If you have 14 records, no scroll bar appears as it isn't needed.
Selecting the last record using the navigation buttons moves the focus but the records displayed do not change as there is no reason for them to do so
Hi Colin,
I do like to understand what I am doing rather than just sticking code in so hence my curiosity. A bit of confusion set in here as I think what I was seeing occurred when there was no If clause. It went to the last record as you state with no scroll bar but then attempted to move back, created the scroll bar, moved the record to the top and then failed due to lack of records.
Time to accept the quirk, many thanks for all your help.