Jan 14 2021 01:59 PM
Jan 14 2021 02:50 PM
@soufiane91 If it is a subform in a main form, then YOU have to fire some code to requery the main form and set focus to the record selected in the subform. If you do it the other way around, and if the Master/Child Linking fields are properly set, then selecting a record in the main form WILL requery the subform, though.
BTW: I don't see a Split form in that screen shot. All I can see is a subform in datasheetview
Jan 15 2021 06:48 AM - edited Jan 15 2021 03:49 PM
Let me see if I can understand the situation a bit better.
You have a main form bound to this query. You also have a SUBform bound to the same query.
You want to show the main form in Single Form View. You want to show the SUBform in Datasheet View.
This is, in fact, a lot like a Split Form would work, is it not? There are some limitations to Split Forms that might make this approach more desirable.
That said, I am not convinced this is such a good idea, so I'm going to offer an alternative and see what you think.
If the point is to use the SUBform to navigate the main form, then a List Box control bound to that same query would do the job and be considerably less work to implement.
If there is another reason to want to have both forms, perhaps you can explain that so I can better understand how it needs to work.
As it is, I can see simply placing the following code (or something similar to it), in the Current Event of the SUBform. I'm not sure I've ever seen this done, so it's sort of a guess about how it ought to work, though.
Private Sub Form_Current()
Dim lngPrimaryKey as Long
Dim rstParentFormRecordSource as DAO.Recordset
lngPrimaryKey = Me.PrimaryKey
Set rstParentFormRecordSource = Me.Parent.Form.RecordsetClone
rstParentFormRecordSource .FindFirst "PrimaryKey = " & lngPrimaryKey
Me.Parent.Recordsource.Bookmark = rstParentFormRecordSource.Bookmark
Set rstParentFormRecordSource = Nothing
Thanks for further clarifying the goal.