I have been trying to do this, but clearly not getting the syntax correct. This is all a bit new to me, so I am not surprised by me getting it wrong!
Underlying my problems are perhaps the fact that my understanding of VBA is poor and so I am really jumping in at the deep end with little understanding of
what some of the terms and statements mean, copying things from elsewhere and by trial and error finding out what works and what doesn't.
My MainForm is called "F_Daily_Overall_Time_Sheet"
My Subform is called "SF_Daily_Job_Time_Sheet"
My PKfield on the MainForm is called "T_ConHoursRecordID".
My PKfield on the SubForm is called "Daily_Record_ID"
The fields on which the AfterUpdate Event is set on the SubForm are:
"SF_Daily_Job_Time_Sheet.Start_time" and "SF_Daily_Job_Time_Sheet.End_time"
My first problem was prompting a requery of a main form following a data update on a subform.
Despite searching all the forums I could find for code to get this to work, I ended up asking a colleague who gave me the code
Private Sub Start_time_AfterUpdate()
Forms("F_Daily_Overall_Time_Sheet").Requery
End Sub
This works, which none of the other things I tried did, but following the requery displays the most recently entered main form record, and puts the focus on the first field of that form which happens to be the date field. I want the form to return to the record current at the time of the requery, and ideally to put the cursor in the next field according to the TabOrder of the form.
For me to understand the code I need to write, I need to understand the processes. I think they are like this:
1.An event triggers the requery of the main form from the subform.
2.The PK of the subform is captured.
3.The PK of the mainform is captured.
4.The form is requeried
5.The previously current record of the mainform is returned to by returning to the captured PK.
6.The focus then needs to be returned to the subform.
7.The previously current subform record is returned to by returning to the captured PK.
8.The focus within the subform is then returned to the field I want
Is this correct?
Thanks alot