By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,773 Members | 2,583 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,773 IT Pros & Developers. It's quick & easy.

Build a reference to a control on the fly

P: n/a
Rob
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
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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" <si****@ensco.com> wrote in message
news:bd************************@posting.google.com ...
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

Nov 13 '05 #2

P: n/a
Rob
I'll try that, but in the meantime, what is the variable type of the variable

gAcCtlStuffResultInto

??
Thanks
"Malcolm Cook" <me*@stowers-institute.org> wrote in message news:<6n**************@news.more.net>...
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" <si****@ensco.com> wrote in message
news:bd************************@posting.google.com ...
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

Nov 13 '05 #3

P: n/a
Rob
I get an "object does not support this property or method" error.
Any ideas?

"Malcolm Cook" <me*@stowers-institute.org> wrote in message news:<6n**************@news.more.net>...
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" <si****@ensco.com> wrote in message
news:bd************************@posting.google.com ...
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

Nov 13 '05 #4

P: n/a
si****@ensco.com (Rob) wrote in message news:<bd************************@posting.google.co m>...
I'll try that, but in the meantime, what is the variable type of the variable

gAcCtlStuffResultInto

??
Thanks


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

dim ctl as Control

set ctl = me!mslbxMultiSelect
....
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.