Eric said:
Thanks MgFoster,
What I want to do is get the name of a text box from a form that opens the report. The record source for the report is a crosstab query, so I can't include the field in the record source.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Not very clear Eric. If there is a form that opens the report you
must know the names of all the TextBoxes on that form since you are
creating the form (aren't you?). Is it the value of one of the
TextBoxes you want to get? If so, where do you want to get it - while
in the form or while in the report?
How to get the value of a TextBox while code is running on the
form/report:
Dim strTextBoxValue As String
strTextBoxValue = Me!txtTheTextBox
Getting the value of a TextBox from another form/report:
Dim strTextBoxValue As String
strTextBoxValue = Forms!frmOtherForm!txtTheTextBox
You can get the TextBox names from the report's OnOpen event or during
one of the report's other events. Here is a method that will allow
you to enumerate all the TextBox names, and their values, of a form
from the report's OnOpen event (it could be used in any Sub or
Function you define):
Private Sub Report_Open(Cancel As Integer)
Dim frm As Form
Dim ctl As Control
Set frm = Forms("form name")
For Each ctl In frm.Controls
If TypeOf ctl Is TextBox Then
Debug.Print ctl.Name, ctl.Value
End If
Next
Set ctl = Nothing
Set frm = Nothing
End Sub
You have to replace the "form name" with the name of the form from
which you want to get the TextBox names. That form has to be open
when the code runs.
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQE9+yIechKqOuFEgEQJDzQCeIHzjTl1S/sbNhFM+lNxIeGiLDCoAoPl0
dY7k8UCRvJZ0TpBa1VfNHr0t
=NMt6
-----END PGP SIGNATURE-----