G
Guest
How do I refer to a txtbox on a report, dynamically, regardless of which
report the user chooses?
I have already read the thread here "assigning value to text box", but one
suggestion to doing this, returned an error, the SetFocus line, at
..txtReportMonthYear, Method or data member not found (Error 461).
My form has a list of possible reports.
When the user selects a report, I capture the actual reportname and use it
to Open the report.
I need to assign a value to a txtbox on that report dynamically.
The suggested code (that errors for me) in the previous thread was:
set a value to its own textbox. And there you'd just use this:
Me.txb_Name1.Value = "12345"
I used:
DoCmd.OpenReport strReport, acViewPreview
Me.txtReportMonthYear.SetFocus
Me.txtReportMonthYear = strReportMonthYear
I have also tried a label and varying the "Me":
Me.lblReportMonthYear
Me.[lblReportMonthYear]
Me. and Me!
I did verify that txtReportMonthYear is the name of the txtbox and I copied
it here for 'proof'. I also placed a lblReportMonth to try a label. It
can't be found either.
Even when I am just in the VBA window and typing in the code, I do get an MS
object dropdown telling me a couple of txt fields and a couple of lbl fields,
but not the ones I placed for the month/year. It's not seeing my field(s),
txt and lbl.
This syntax is correct, I think, but requires the name of the report:
' Reports![rR1-E].Report![txtTimePeriod].SetFocus
' Reports![rR1-E]![txtTimePeriod] = strTimePeriod
report the user chooses?
I have already read the thread here "assigning value to text box", but one
suggestion to doing this, returned an error, the SetFocus line, at
..txtReportMonthYear, Method or data member not found (Error 461).
My form has a list of possible reports.
When the user selects a report, I capture the actual reportname and use it
to Open the report.
I need to assign a value to a txtbox on that report dynamically.
The suggested code (that errors for me) in the previous thread was:
set a value to its own textbox. And there you'd just use this:
Me.txb_Name1.Value = "12345"
I used:
DoCmd.OpenReport strReport, acViewPreview
Me.txtReportMonthYear.SetFocus
Me.txtReportMonthYear = strReportMonthYear
I have also tried a label and varying the "Me":
Me.lblReportMonthYear
Me.[lblReportMonthYear]
Me. and Me!
I did verify that txtReportMonthYear is the name of the txtbox and I copied
it here for 'proof'. I also placed a lblReportMonth to try a label. It
can't be found either.
Even when I am just in the VBA window and typing in the code, I do get an MS
object dropdown telling me a couple of txt fields and a couple of lbl fields,
but not the ones I placed for the month/year. It's not seeing my field(s),
txt and lbl.
This syntax is correct, I think, but requires the name of the report:
' Reports![rR1-E].Report![txtTimePeriod].SetFocus
' Reports![rR1-E]![txtTimePeriod] = strTimePeriod