Keep Cursor in same spot after Requery

omarrr128

Member
Local time
Today, 17:43
Joined
Feb 5, 2023
Messages
72
Currently in My database there is an area for Staff to add some notes. Problem is that when the form does a Requery the cursor will move to a field in the top Record and also selects all the data in that record.

Is it possible to keep the Cursor in the exact same spot after query so Staff can carry on typing like nothing happened and without being interrupted?

Im not very good with code so if someone could write out code for me I would be very grateful :).

File attached if it helps.

 

Attachments

instead of Me.Requery, you can use Me.Recordset.Requery
 
instead of Me.Requery, you can use Me.Recordset.Requery
i tried that. It keeps it on the same record instead of going to the top one but it will still select all the data in the field. i need some code for it to go to the end of the field. I tried to do the sel start and length but couldnt get far
 
Check out the recordset absoluteposition property. On my phone so can’t really do any more than something like

dim p as long
Dim s as long
S=myfield.selstart
P=me.recordset.absoluteposition
Me.requery
me.recordset.absoluteposition=p
Myfield.selstart=s

Will need more work jf the form is scrollable and the form has been scrolled
 
try this.
It half worked. In most cases it works but if a new job is booked and all the records shift down by 1 row then it will edit the row that has moved down in to its place. I have found a fix though and just made it that setfocus after requery goes to a locked textbox.

Thank you :)

I was looking more in to the previous request i had with locking the start time and found this link. Do you think could install it? Ive tried switching the names out but it doesnt seem to work at all.

 
Requery is NOT the method intended for saving the current record. Requery tells Access to rerun the form's RecordSource query and since that reloads the form's RecordSource, focus moves back to the first row. Saving the current row is a side effect of Requery and therefore, you are experiencing unintended consequences by using the wrong command.

Use
DoCmd.RunCommand acCmdSaveRecord


or

Me.Dirty = False --- but always document this since it is not obvious what it does.
 
Problem is that when the form does a Requery the cursor will move to a field in the top Record and also selects all the data in that record.
What is the use of the requery?
 
What is the use of the requery?
just to refresh the page automatically so new jobs appear. I have found a decent fix for it which is just to set focus to a text box that cant be edited so no text will be entered anywhere after requery if that makes sense
 

Users who are viewing this thread

Back
Top Bottom