Using a Query/Datasheet subform on a Main Form app where the subform is in control
The application works well once it is running ... however ... I haven't found an event that I can call:
Code:
Application.RunCommand acCmdSelectRecord
to select the first record on the query subform
when the Application starts
This behaves like a cart before the horse issue ... when the app starts, even though subform events run
first, Access hasn't actually given focus or drawn the subform ... I expect that acCmdSelectRecord requires
the object it is intended to paint to already exist on the screen ... I haven't been able to find an event that
fires after the initial application is drawn ... I could possibly add a one shot timer that would trap all user
input until it times out ... this would also call the acCmdSelectRecord ... however ....
was hoping someone would have a simpler solution
Details
Access runs all the subform events first before calling the Main Form Events
Query subForm Open
Query subForm Load
Query subForm Current ' Calls subRecordSelect
Main Form Current ' passes focus to the subForm
Main Form subForm frmQuery_Enter
I have a sub on the Query subForm that does the Record Select
Code:
Sub subRecordSelect(ByVal chSel As String)
On Error GoTo endSelect
Call dbg("Query subRecordSelect --- " & chSel)
Application.RunCommand acCmdSelectRecord ' select entire record row
endSelect:
End Sub
I just expected to call subRecordSelect directly from the last event fired to get the record to select ... I tried adding it to Form Current and Query_enter but this doesn't do anything ... the first record is selected but only the first field is highlighted instead of the entire row.
Once the application is running the events fire in the following order for each key or mouse click (mouse and keydown events all flow through fnKeydown)
Query fnKeyDown
Query subRecordSelect ' updates the record selection
Main Form subKeyin ' this is also a mouse / key click trap
Main Form subUpdateScreen ' expands details on the main form about the query record
Navigation:
left and right arrows trigger a spin button which changes the Month Year of the Query
up and down arrows trigger record scrolling on the subform
all movement updates further related details of the current record on the main form