Connecting Tech Pros Worldwide Help | Site Map

Build a reference to a control on the fly

Rob
Guest
 
Posts: n/a
#1: Nov 13 '05
THere must be an easy way to do the following, but I'm drawing a
blank.

I have 2 forms frmA and frmB. I double click on a text box in frmA
and open frmB. In frmB, I select an item and close. On the close
button I stuff the selected value back into the text box on frmA via.
I need to make frmB generic so it can stuff its value back into the
same type of text box on MANY different forms in my app. I pass in
the name of the calling form via OpenArgs tp frmB.

This works fine in frmB when frmA is not a subform:

Forms(Me.OpenArgs).ActiveControl.Value = me.ID

But I need to be able to do this from a subform.
When sfrmA is a subform, I can't figure out a way to let frmB find the
control on subform sfrmA to stuff the value into:

Hardcoded, this works fine:

Forms!mfrmA!sfrmA.Form!myID = Me.ID

But I can't find a way to pass in (essentially) this string
"Forms!mfrmA!sfrmA.Form!myID" and Assign Me.ID to it generically.

Any help would be greatly appreciated!!
Thanks,
Rob
Malcolm Cook
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Build a reference to a control on the fly


before opening frmB, set a global variable, as follows

set gAcCtlStuffResultInto = Screen.ActiveForm.ActiveControl

then, in frmB, use the following

gAcCtlStuffResultInto.value = me.ID




"Rob" <sindle@ensco.com> wrote in message
news:bd910ee.0408200633.3c06fe6@posting.google.com ...[color=blue]
> THere must be an easy way to do the following, but I'm drawing a
> blank.
>
> I have 2 forms frmA and frmB. I double click on a text box in frmA
> and open frmB. In frmB, I select an item and close. On the close
> button I stuff the selected value back into the text box on frmA via.
> I need to make frmB generic so it can stuff its value back into the
> same type of text box on MANY different forms in my app. I pass in
> the name of the calling form via OpenArgs tp frmB.
>
> This works fine in frmB when frmA is not a subform:
>
> Forms(Me.OpenArgs).ActiveControl.Value = me.ID
>
> But I need to be able to do this from a subform.
> When sfrmA is a subform, I can't figure out a way to let frmB find the
> control on subform sfrmA to stuff the value into:
>
> Hardcoded, this works fine:
>
> Forms!mfrmA!sfrmA.Form!myID = Me.ID
>
> But I can't find a way to pass in (essentially) this string
> "Forms!mfrmA!sfrmA.Form!myID" and Assign Me.ID to it generically.
>
> Any help would be greatly appreciated!!
> Thanks,
> Rob[/color]


Rob
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Build a reference to a control on the fly


I'll try that, but in the meantime, what is the variable type of the variable

gAcCtlStuffResultInto

??
Thanks


"Malcolm Cook" <mec@stowers-institute.org> wrote in message news:<6noVc.81$i_4.432@news.more.net>...[color=blue]
> before opening frmB, set a global variable, as follows
>
> set gAcCtlStuffResultInto = Screen.ActiveForm.ActiveControl
>
> then, in frmB, use the following
>
> gAcCtlStuffResultInto.value = me.ID
>
>
>
>
> "Rob" <sindle@ensco.com> wrote in message
> news:bd910ee.0408200633.3c06fe6@posting.google.com ...[color=green]
> > THere must be an easy way to do the following, but I'm drawing a
> > blank.
> >
> > I have 2 forms frmA and frmB. I double click on a text box in frmA
> > and open frmB. In frmB, I select an item and close. On the close
> > button I stuff the selected value back into the text box on frmA via.
> > I need to make frmB generic so it can stuff its value back into the
> > same type of text box on MANY different forms in my app. I pass in
> > the name of the calling form via OpenArgs tp frmB.
> >
> > This works fine in frmB when frmA is not a subform:
> >
> > Forms(Me.OpenArgs).ActiveControl.Value = me.ID
> >
> > But I need to be able to do this from a subform.
> > When sfrmA is a subform, I can't figure out a way to let frmB find the
> > control on subform sfrmA to stuff the value into:
> >
> > Hardcoded, this works fine:
> >
> > Forms!mfrmA!sfrmA.Form!myID = Me.ID
> >
> > But I can't find a way to pass in (essentially) this string
> > "Forms!mfrmA!sfrmA.Form!myID" and Assign Me.ID to it generically.
> >
> > Any help would be greatly appreciated!!
> > Thanks,
> > Rob[/color][/color]
Rob
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Build a reference to a control on the fly


I get an "object does not support this property or method" error.
Any ideas?



"Malcolm Cook" <mec@stowers-institute.org> wrote in message news:<6noVc.81$i_4.432@news.more.net>...[color=blue]
> before opening frmB, set a global variable, as follows
>
> set gAcCtlStuffResultInto = Screen.ActiveForm.ActiveControl
>
> then, in frmB, use the following
>
> gAcCtlStuffResultInto.value = me.ID
>
>
>
>
> "Rob" <sindle@ensco.com> wrote in message
> news:bd910ee.0408200633.3c06fe6@posting.google.com ...[color=green]
> > THere must be an easy way to do the following, but I'm drawing a
> > blank.
> >
> > I have 2 forms frmA and frmB. I double click on a text box in frmA
> > and open frmB. In frmB, I select an item and close. On the close
> > button I stuff the selected value back into the text box on frmA via.
> > I need to make frmB generic so it can stuff its value back into the
> > same type of text box on MANY different forms in my app. I pass in
> > the name of the calling form via OpenArgs tp frmB.
> >
> > This works fine in frmB when frmA is not a subform:
> >
> > Forms(Me.OpenArgs).ActiveControl.Value = me.ID
> >
> > But I need to be able to do this from a subform.
> > When sfrmA is a subform, I can't figure out a way to let frmB find the
> > control on subform sfrmA to stuff the value into:
> >
> > Hardcoded, this works fine:
> >
> > Forms!mfrmA!sfrmA.Form!myID = Me.ID
> >
> > But I can't find a way to pass in (essentially) this string
> > "Forms!mfrmA!sfrmA.Form!myID" and Assign Me.ID to it generically.
> >
> > Any help would be greatly appreciated!!
> > Thanks,
> > Rob[/color][/color]
Pieter Linden
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Build a reference to a control on the fly


sindle@ensco.com (Rob) wrote in message news:<bd910ee.0408201039.5522edd@posting.google.co m>...[color=blue]
> I'll try that, but in the meantime, what is the variable type of the variable
>
> gAcCtlStuffResultInto
>
> ??
> Thanks[/color]

a control... that's about as clear as mud...

dim ctl as Control

set ctl = me!mslbxMultiSelect
....
Closed Thread


Similar Microsoft Access / VBA bytes