vba - Reselect active cell in Access subform following requery -


i have subform displaying data set containing 200 rows , 35 columns. when user selects cell part of ui enabled allowing them add/edit records, following subform needs refresh user can see effect of changes, triggered afterupdate event.

the issue have when subform refreshed, calling requery, focus shifted top left of subform, meaning not can user not see effect of change, have lost place.

i have managed subform reselect current record capturing , setting form.recordset.absoluteposition property, can't find way set focus column user in previously.

the code have is:

private sub form_afterupdate()      dim lngcurrentpos long      form_frmmain.subfrm_results_review         lngcurrentpos = .form.recordset.absoluteposition         .requery         .form.recordset.absoluteposition = lngcurrentpos     end  end sub 

but there anyway set focus specific cell? seems there should way must common problem?

you can set focus selected control of form extending vba code follows.

private sub form_afterupdate()      dim lngcurrentpos long     dim strcontrolname string      form_frmmain.subfrm_results_review         strcontrolname = .form.activecontrol.name         lngcurrentpos = .form.recordset.absoluteposition         .requery         .form.recordset.absoluteposition = lngcurrentpos         .form.controls(strcontrolname).setfocus     end  end sub 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -