Hi,
Wondering if someone can help me, I created a previous thread which got extremely messy, so I have removed that one and created a new one.
I hold all of my subforms within one main form as depicted in this screenshot here:
I have a field called Book Discount on my Publisher Info Subform. This field is also present, albeit under a different name on the Marketing Template Subform. What should happen is that, whenever Book Discount on the Publisher Info Subform is changed, it should automatically update the Book Discount on the Marketing Template Subform. This field is set to disabled, so it cannot be changed. It's purely there for display purposes only.
I have done the following to try and achieve this:
I have this code that I have modified from another member on here, that works correctly when linking different fields from the the main form to different fields on various subforms:
I have tried to adapt this to work for my subform to subform but I get the same error as shown here:
VBA then highlights the Subform name as error.
So what am I doing wrong as I can't seem to figure this out?
Wondering if someone can help me, I created a previous thread which got extremely messy, so I have removed that one and created a new one.
I hold all of my subforms within one main form as depicted in this screenshot here:
I have a field called Book Discount on my Publisher Info Subform. This field is also present, albeit under a different name on the Marketing Template Subform. What should happen is that, whenever Book Discount on the Publisher Info Subform is changed, it should automatically update the Book Discount on the Marketing Template Subform. This field is set to disabled, so it cannot be changed. It's purely there for display purposes only.
I have done the following to try and achieve this:
On Marketing Template Subform, in Design View, I created an Unbound Combobox called Unbound_BookDiscount.
I set the control source to be:
Code:Forms![frm_Publisher_Info_Subform]![Book_Discount_Code]
Because when Book Discount Code on the Publisher Info Subform is changed, I want this Unbound control to be changed.
I then went to the Publisher Info Subform and clicked the combobox called Book Discount Code. I clicked on Event and then clicked on After Update and selected Event Procedure. I then clicked on the 3 dots and it opened VBA. I then have this code from a contributor on this forum, modified to work in my application:
Code:Private Sub Book_Discount_Code_AfterUpdate() Me.frm_Marketing_Subform.Form.Unbound_BookDiscount.Requery End Sub
Which as I understand it says, When Book Discount Code is updated, requery the combobox Unbound_Book Discount on the Marketing Subform.
Save.
Right click main form and click on Form View and test by changing Book Discount Code on Publisher Info Subform.
I then get the following error:
Code:Compile Error: Method or data member not found
VBA then automatically highlights the following:
Code:.frm_Marketing_Subform
Which from what I understand, is saying the subform name is wrong or not found but I know the naming is correct as I have in another block of code that references it and it works correctly. I copied and pasted the name into the new code.
I have this code that I have modified from another member on here, that works correctly when linking different fields from the the main form to different fields on various subforms:
Code:
Private Sub product_group_code_afterupdate()
With Me.frm_Marketing_Subform.Form
!Product_Group = Me.Product_Group_Code
.Dirty = False
End With
With Me.frm_Publishing_Info_Subform.Form
!Contract_Type_Product_Group = Me.Product_Group_Code
.Dirty = False
End With
End Sub
I have tried to adapt this to work for my subform to subform but I get the same error as shown here:
Code:
Compile Error:
Method or data member not found
VBA then highlights the Subform name as error.
So what am I doing wrong as I can't seem to figure this out?
Last edited: