Reassigning SourceObject of subform

Wysy

Registered User.
Local time
Today, 11:04
Joined
Jul 5, 2015
Messages
335
hi,
i need to reassign sourceobject of a subform control on a form after filtering is applied. How do i do it?
thanks
 
assuming you are filtering in vba then using vba code

me.subformname.sourceobject="newformname"

but what is the point of filtering if the form is changed?
 
thanks for the fast answer.
So the situation is like this. I have a form. Said form has two subforms linked together. Master form is in datasheet view, child form is simple form view. Scrolling through master form results in data shown in simple view in child form. In case user filters the datasheet view child form shows nothing. The point is to access those filtered data in child form as well. I have read about solving this by reassigning the sourceobject of child form. I see why it would work, but what code needs to be used?
 
but what code needs to be used?
I provided the code

from your more complete description, I would think the reason you have the problem is that the datasheet form has not been assigned a current record so not sure that solution would work anyway. If so you need code to go to a record - perhaps something like

docmd.gotorecord acfirst

I'm signing off now, and won't be back for a few days so if either solution doesn't work, hopefully someone else will pick it up
 
In post #1 you need to change the SourceObject property. In post #3 you need to synchronize two different subforms. For best results, in post #6 take the time to describe the entire problem that you need help with. You are asking us to take time to help you. Please, you first, take the time to describe the problem.
Hope this helps,
Mark
 
Sorry if i was not clear enough.
So subform1 contains the records of tbCustomers with names address, etc. in datasheet view. I did this to see records as kind of a list
Subform2 contains records of the same table, but in single form view to see the data as one page. The two forms are related to eachother as master/child based on customerID
This is works fine.
However if i try to use the quick filter of customers column in datasheet view the subform2 does not requery itself but stays blank. Somewhere i read that this can be solved by reassingning sourceobject of subform2.
 
how did you linked both subform. you know you can't directly linked them. you need a dummy Textbox on the Main Form.

on the current event of Subform1 set Textbox value:

Private Sub Form_Current:
On Error Resume Next
Me.Parent.TextBox=Me.CustomerID
End Sub


now you create Master/Chilld link field on subform2 using TextBox, And CutomerID
 
This still does not make sense to me. You seem to explain that the forms are synchronized and that the synchronization works fine...
The two forms are related to eachother as master/child based on customerID
This is works fine.
...but then you go on to explain that there is a problem with the synchronization...
However if i try to use the quick filter of customers column in datasheet view the subform2 does not requery itself but stays blank.
As a result of this conflict in your explanation of the problem, I don't understand the problem, and don't know what to suggest.
hth
Mark
 
Mark, yes it is exactly the situation. The normal syncronization process is working fine before filtering but fails to perform correctly after filtering. I have tested the forms and found that after filtering subform1, the sourceobject of subform2 disappears. I have read about this and there was the suggestion to reassing sourceobject of subform2. But now i found the solution.
Private Sub Form_Current()
Me.Parent.Controls!subform2.Requery
Me.Parent.Controls!subform2.SourceObject = "xy"
Me.Parent.Controls!subform2.LinkChildFields = "customeID"
Me.Parent.Controls!subform2.LinkMasterFields = "subform1!customerID"
End Sub
This way it works with and without filtering.
 

Users who are viewing this thread

Back
Top Bottom