1
votes

I am trying to pass a variable from a Modal Form to a subform within a subform and unable to create the proper syntax. Subform "sfrProfiling" is contained within subform "Crafter Default" which is contained within "Main Form". I have a modal pop up with the name "sfrChangeProfilePics". I can create the variable without a problem, but cannot pass the varible value to the field "pic" on the subform "sfrProfiling'.The error says it cannot find the field.

These subforms are also in navigation subforms as well.

Update:

I am trying to pass a variable from a Modal Form (sfrChangeProfilePics), to a subform in a NavigationSubform (sfrProfiling), to a subform in a NavigationSubform (Crafter Default) which is in the main form (Main Form) and unable to create the proper syntax. My code works when they are simply a subform within a subform within the main form. As soon as I insert them into navigation control it doesn't work. My navigationSubform name is "NavigationSubform".

My code is as follows:

Public Sub Command4_Click()
Dim myProfiling As Recordset

Set myProfiling = CurrentDb.OpenRecordset("Profiling")
varChangePicture = Forms!sfrChangeProfilePics!FileName.value

DoCmd.Close

Forms![Main Form].[Crafter Default].Form!sfrProfiling.Form!pic.value=varChangePicture

End Sub
1
Syntax is correct if Crafter Default is the name of the subform control. - Gustav
Yes. Check and re-check for typos. Reference: access.mvps.org/access/forms/frm0031.htm -- Forms!Mainform!Subform1.Form!Subform2.Form!ControlName - Andre
Alternatively you can pass the variable to a hidden control on the main form from your modal, and have your sub-subform pick up that value from the main form. - Johnny Bones
I failed to mention that these subforms are in a navigation subform. Does that change the syntax? - John Wolfenstein
@Gustav my code works when it's not in a navigation subform. As soon as I put the subforms into navigationSubforms it gives me an error. I think the problem is within the syntax on how to call the value within the navigationSubform that is within the navigationSubform that is within the MainForm. - John Wolfenstein

1 Answers

3
votes

This works:

Forms![Main Form].MainNavsfr.Form!CrafterDefaultNavsfr.Form!pic.value = varChangePicture