PC Review


Reply
Thread Tools Rate Thread

control name literal

 
 
PeterM
Guest
Posts: n/a
 
      4th Jun 2010
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!
 
Reply With Quote
 
 
 
 
Tom van Stiphout
Guest
Posts: n/a
 
      4th Jun 2010
On Thu, 3 Jun 2010 17:36:37 -0700, PeterM
<(E-Mail Removed)> 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!

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extend Literal Control shapper Microsoft ASP .NET 0 17th Dec 2006 05:43 PM
Literal control won't expand Mark A. Sam Microsoft ASP .NET 5 28th Jun 2006 02:27 PM
Literal Control question Mark A. Sam Microsoft ASP .NET 2 22nd Jun 2006 06:42 PM
Literal control - why? VB Programmer Microsoft ASP .NET 3 10th Jun 2004 02:38 PM
Re: Literal Control and Onclick? Mike Prager Microsoft ASP .NET 0 14th Oct 2003 09:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:22 PM.