soufiane91
Jan 14, 2021Copper Contributor
split form inside a form
I Insert I split form inside a form that have the same query , so when I click on a row on that split form the form does not change . is there an event or macro ??
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
maybe I didn't explain clearly . I want to Display a form and its datasheet " like a split form" but me I dont want a split form I want to create a form and its datasheet .
Thank you for clarifying that. Because a "Split Form" is a very specific type of form, I was a bit confused.
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
End Sub
Thanks for further clarifying the goal.