Connecting Tech Pros Worldwide Help | Site Map

Build a reference to a control on the fly

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 01:54 AM
Rob
Guest
 
Posts: n/a
Default Build a reference to a control on the fly

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

  #2  
Old November 13th, 2005, 01:54 AM
Malcolm Cook
Guest
 
Posts: n/a
Default 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]


  #3  
Old November 13th, 2005, 01:54 AM
Rob
Guest
 
Posts: n/a
Default 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]
  #4  
Old November 13th, 2005, 01:54 AM
Rob
Guest
 
Posts: n/a
Default 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]
  #5  
Old November 13th, 2005, 01:54 AM
Pieter Linden
Guest
 
Posts: n/a
Default 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
....
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.