473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

fGetControl (strMyControl) as Control

BUX
Do you know if exist a functione that returns a controle using as
string?
For example
Dim MyControl as Control
MyControl= fGetControl("Forms![MyForm]![MySubForm].form![MyControl] ")

thank you
Nov 13 '05 #1
8 1230
BUX wrote in message <v2********************************@4ax.com> :
Do you know if exist a functione that returns a controle using as
string?
For example
Dim MyControl as Control
MyControl= fGetControl("Forms![MyForm]![MySubForm].form![MyControl] ")

thank you


I'm not entirely sure what you're asking, but see if this is along the
lines of
what you need:

dim strCtl as string
dim strFrm as string
strCtl = "txtMyControl"
strFrm = "frmMyForm"
debug.print forms(strFrm).controls(strCtl).value

--
Roy-Vidar

Nov 13 '05 #2
BUX
Yes this is what I mean, but the function have to Work with or without
subForm.

thanks

On Wed, 27 Jul 2005 13:41:29 GMT, "RoyVidar"
<ro*************@yahoo.no> wrote:
BUX wrote in message <v2********************************@4ax.com> :
Do you know if exist a functione that returns a controle using as
string?
For example
Dim MyControl as Control
MyControl= fGetControl("Forms![MyForm]![MySubForm].form![MyControl] ")

thank you


I'm not entirely sure what you're asking, but see if this is along the
lines of
what you need:

dim strCtl as string
dim strFrm as string
strCtl = "txtMyControl"
strFrm = "frmMyForm"
debug.print forms(strFrm).controls(strCtl).value


Nov 13 '05 #3
BUX wrote in message <m6********************************@4ax.com> :
Yes this is what I mean, but the function have to Work with or without
subForm.

thanks

On Wed, 27 Jul 2005 13:41:29 GMT, "RoyVidar"
<ro*************@yahoo.no> wrote:
BUX wrote in message <v2********************************@4ax.com> :
Do you know if exist a functione that returns a controle using as
string?
For example
Dim MyControl as Control
MyControl= fGetControl("Forms![MyForm]![MySubForm].form![MyControl] ")

thank you


I'm not entirely sure what you're asking, but see if this is along the
lines of
what you need:

dim strCtl as string
dim strFrm as string
strCtl = "txtMyControl"
strFrm = "frmMyForm"
debug.print forms(strFrm).controls(strCtl).value


Sorry, i still don't understand what you're intending to do...

If you're attempting to find a control on a form containing
subform(s), where the control can be either on the main
form or one of the sub forms, then I think you'll need a
recursive sub or something - but again, with the
description you've given, I don't understand where
to start...

--
Roy-Vidar

Nov 13 '05 #4
BUX

I would like to know if there is a function like this
Public Function fGetControl("strControl as String") as Control

so I can set MyControl from a string like this
"Forms![MyForm]![MySubForm].form![MyControl] "

If it do not exist I am able to write it.

Than you for your interesting.

On Wed, 27 Jul 2005 17:16:36 GMT, "RoyVidar"
<ro*************@yahoo.no> wrote:
BUX wrote in message <m6********************************@4ax.com> :
Yes this is what I mean, but the function have to Work with or without
subForm.

thanks

On Wed, 27 Jul 2005 13:41:29 GMT, "RoyVidar"
<ro*************@yahoo.no> wrote:
BUX wrote in message <v2********************************@4ax.com> :
Do you know if exist a functione that returns a controle using as
string?
For example
Dim MyControl as Control
MyControl= fGetControl("Forms![MyForm]![MySubForm].form![MyControl] ")

thank you

I'm not entirely sure what you're asking, but see if this is along the
lines of
what you need:

dim strCtl as string
dim strFrm as string
strCtl = "txtMyControl"
strFrm = "frmMyForm"
debug.print forms(strFrm).controls(strCtl).value


Sorry, i still don't understand what you're intending to do...

If you're attempting to find a control on a form containing
subform(s), where the control can be either on the main
form or one of the sub forms, then I think you'll need a
recursive sub or something - but again, with the
description you've given, I don't understand where
to start...


Nov 13 '05 #5
"RoyVidar" <ro*************@yahoo.no> wrote in
news:mn***********************@yahoo.no:
If you're attempting to find a control on a form containing
subform(s), where the control can be either on the main
form or one of the sub forms, then I think you'll need a
recursive sub or something - but again, with the
description you've given, I don't understand where
to start...


No, you'll just need to know to pass the fully qualified form name:

fGetControl(Forms!frmParent!SubForm.Form, "controlname")

and you'll need to change your function definition so the first
argument is of type FORM, rather than a string.

I'm wondering if we're providing the solution that was asked for,
but one that wouldn't be the best if we knew *why* this solution was
requested.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #6
BUX
I often have to search in a form (Form1) a value for another form
(Form2).
So I have done a table where i placed fields like this:

Field1
Forms!Form1!Control1

Field2
Forms!Form2!Control2.

I have to do a function that set Forms!Form1!Control1 with the value
in Forms!Form2!Control2 .

I want to use a variable like this

Public MyControl as Control

to pass the value from
Forms!Form1!Control1
to
Forms!Form2!Control2.

So I need a function like
Set MyControl = fGetControl(strMyControl).

Excuse me for my bed English

thanks

No, you'll just need to know to pass the fully qualified form name:

fGetControl(Forms!frmParent!SubForm.Form, "controlname")

and you'll need to change your function definition so the first
argument is of type FORM, rather than a string.

I'm wondering if we're providing the solution that was asked for,
but one that wouldn't be the best if we knew *why* this solution was
requested.


Nov 13 '05 #7
BUX <pi***@pippo.it> wrote in
news:25********************************@4ax.com:
I often have to search in a form (Form1) a value for another form
(Form2).
So I have done a table where i placed fields like this:

Field1
Forms!Form1!Control1

Field2
Forms!Form2!Control2.

I have to do a function that set Forms!Form1!Control1 with the
value in Forms!Form2!Control2 .

I want to use a variable like this

Public MyControl as Control

to pass the value from
Forms!Form1!Control1
to
Forms!Form2!Control2.

So I need a function like
Set MyControl = fGetControl(strMyControl).


Why not give the controls the same name on both forms?

Then you could do:

Forms!Form2(Forms!Form1!Control1.Name) = Forms!Form1!Control1

I'm assuming you want this to be done with a variable, so you can,
for instance, walk through a collection of controls and do the
assignment:

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
Forms!Form2(ctl.name) = ctl
End If
Next ctl

Set ctl = Nothing

Now, if you really wanted to abstract this, you could do something
like:

Public Sub SetFormValues(frmSource as Form, frmDestination As frm)
Dim ctl As Control

For Each ctl In frmSource.Controls
If ctl.ControlType = acTextBox Then
frmDestination(ctl.name) = ctl
End If
Next ctl

Set ctl = Nothing
End Sub

Does that help?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #8
BUX
It is a good idea!
English people always pragmatic!
Thank you very much

On Thu, 28 Jul 2005 17:28:41 -0500, "David W. Fenton"

Why not give the controls the same name on both forms?

Then you could do:

Forms!Form2(Forms!Form1!Control1.Name) = Forms!Form1!Control1

I'm assuming you want this to be done with a variable, so you can,
for instance, walk through a collection of controls and do the
assignment:

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
Forms!Form2(ctl.name) = ctl
End If
Next ctl

Set ctl = Nothing

Now, if you really wanted to abstract this, you could do something
like:

Public Sub SetFormValues(frmSource as Form, frmDestination As frm)
Dim ctl As Control

For Each ctl In frmSource.Controls
If ctl.ControlType = acTextBox Then
frmDestination(ctl.name) = ctl
End If
Next ctl

Set ctl = Nothing
End Sub

Does that help?


Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Greg Christie | last post by:
I think I have a somewhat unique situation here, so I thought I should post it for the few poor souls who run across it and try to google it like I did. First of all, I was getting the following...
6
by: Bruce Rusk | last post by:
I'm using Stephen Lebans' RTF2 control in a report, and have discovered what may be a slight bug in it. I have a lot of non-Western language (Chinese) text in my RTF field, and such records get...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.