![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
I have a form in AC2003. FormA calls FormB with the OpenArgs set to the
control name on FormA to populate the results of FormB. My users are selecting a time which is on FormB. Because this function is needed for about 20 other forms, I have created a generic FormB. The openargs being used by the OpenForm from FormA consists of a string name which represents of the fully qualified control name back on FormA to receive the calculated value of FormB. For example FormA calls FormB by: DoCmd.OpenForm "FormB", , , , , acDialog, "forms!sidemenu!formnameonly.form.PD_Med_1_Tim e" This works fine. PD_Med_1_Time is the control on FormA to receive the calculated value in FormB. I'm having problems in FormB when I try to populate the control PD_Med_1_Time on FormA. I've tried forms(FormAControlName)=FormBValue and all other variations that I can think of, but it won't work. How do you refer to a control on another form when you have the full form name and control name as a literal value? Actually, SideMenu contains a control for a subform "FormNameOnly" and "FormNameOnly" has a subform control on it "FormA". THe layering differs on different forms and is not a constant. Below is the code in FormB when it's time to send the calculated value back to FormA. Forms!SideMenu!FormNameOnly.Form.PD_Med_1_Time = FormBValue where PD_Med_1_Time is the control on FormA to be populated and FormBValue is the calculated value in FormB. Any help would be greatly appreciated...thank you! |
#2
|
|||
|
|||
![]()
On Thu, 3 Jun 2010 17:36:37 -0700, PeterM
wrote: To dynamically refer to a control on a form use: Forms(strFormName).Controls(strControlName) This also suggests what you should pass in through OpenArgs: a form name and a control name. Personally I would use a querystring-like argument: FName=myForm&Ctl=myControl Then I write a generic function that can split such term on the & as well as on the = and assign it to a scripting.dictionary object. You don't have to get that fancy and for example pass this in via OpenArgs: myFormName,myControlName Then use the Split function on the comma to pick apart the two values. Then write the control reference like this: dim strTokens() as string strTokens = Split(OpenArgs, ",") The control reference would be: Forms(strTokens(0)).Controls(strTokens(1)) -Tom. Microsoft Access MVP I have a form in AC2003. FormA calls FormB with the OpenArgs set to the control name on FormA to populate the results of FormB. My users are selecting a time which is on FormB. Because this function is needed for about 20 other forms, I have created a generic FormB. The openargs being used by the OpenForm from FormA consists of a string name which represents of the fully qualified control name back on FormA to receive the calculated value of FormB. For example FormA calls FormB by: DoCmd.OpenForm "FormB", , , , , acDialog, "forms!sidemenu!formnameonly.form.PD_Med_1_Time " This works fine. PD_Med_1_Time is the control on FormA to receive the calculated value in FormB. I'm having problems in FormB when I try to populate the control PD_Med_1_Time on FormA. I've tried forms(FormAControlName)=FormBValue and all other variations that I can think of, but it won't work. How do you refer to a control on another form when you have the full form name and control name as a literal value? Actually, SideMenu contains a control for a subform "FormNameOnly" and "FormNameOnly" has a subform control on it "FormA". THe layering differs on different forms and is not a constant. Below is the code in FormB when it's time to send the calculated value back to FormA. Forms!SideMenu!FormNameOnly.Form.PD_Med_1_Time = FormBValue where PD_Med_1_Time is the control on FormA to be populated and FormBValue is the calculated value in FormB. Any help would be greatly appreciated...thank you! |
Thread Tools | |
Display Modes | |
|
|