Salad wrote:
I have a sub routine that I'd like to use to get data from a main form
or from a subform preferably using 1 variable. Ex:
If Me.OpenArgs = "SF" Then
strForm = "MF!SF"
Else
strForm = "MF"
Endif
Me.Text1 = Forms(strForm)!Text1
This doesn't work, sadly. I know that I can get the value by getting
Me.Text1 inside of each part of the if statement. Is there a way to do
this or should I just separate the sub into two parts; data from a
single form, data from a subform.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Here we run into the problem of form vs. subform. When a form is a
SourceObject of a subform control it is not considered an open form.
Therefore, referring to a subform as Forms(subFormName)!Text1 will not
work, 'cuz Forms() only refers to open forms.
However, you can set up a form reference to reference the appropriate
form. E.g.:
Dim frm As Form
If Me.OpenArgs = "SF" Then
' This sets the form reference to the sub-form
Set frm = Forms!MF!SF.Form
Else
' This sets the form reference to the main form
Set frm = Forms!MF
Endif
Me!Text1 = frm!Text1
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQIXB64echKqOuFEgEQJ5PACdHmUkG3DtKVIq1XKUcqEGPX rjl+UAoLLy
79LQ5qCE1RezVCMRyFWsBO4u
=w228
-----END PGP SIGNATURE-----