Me.TheTextBox = Me.OpenArgs
Use a combo or if you want something more visual, use an option group. In the Click event, you Open the report and pass in the chosen argument which may or may not be equal to what the choice is. So the choice might be Male/Female/Other and the hidden values could be 1, 2, 3. It is the hidden values that would be used as the argument in the Where option as you open the report. I wouldn't use the OpenArgs for this task. Using the combo, if you add a third option, you just add the new option to the List Values. If you use an Option group, you have to change the form's design to show a third option. Neither option requires code changes.I have a form that I open a report. I have two buttons that filter the report depending on which button is clicked. I want to have at the top of report a title or text box that will show which button was clicked I tried openargs in the onclick of the button and set the source of text box to be =openargs but that doesn't work
Private Sub cmdOpenReport_Click()
Dim strOpenArgs As String
strOpenArgs = "Open Args Value"
DoCmd.OpenReport "rptTestOpenArgs", acViewPreview, , , , strOpenArgs
End Sub
perfect, I was lazyThe simple way to display openargs is with a text box with a control source of:
=[OpenArgs]
Code:Private Sub cmdOpenReport_Click() Dim strOpenArgs As String strOpenArgs = "Open Args Value" DoCmd.OpenReport "rptTestOpenArgs", acViewPreview, , , , strOpenArgs End Sub
View attachment 118137
I had left the original code that I had used in my trial an error before I posted and when I changed it, I didn't pay attention.Your code doesn’t match mine. I didn’t have an “=“ or "strOpenArgs" (in quotes) in my OpenReport code.
How do you set the values for this table. It would help me by choosing number when the open report is clicked and set textbox in report to the company name.The simple way to display openargs is with a text box with a control source of:
=[OpenArgs]
Code:Private Sub cmdOpenReport_Click() Dim strOpenArgs As String strOpenArgs = "Open Args Value" DoCmd.OpenReport "rptTestOpenArgs", acViewPreview, , , , strOpenArgs End Sub
View attachment 118137
Private Sub cmdOpenReport_Click()
Dim strOpenArgs As String
Dim strWhere As String
strOpenArgs = Me.cboOpenArgsValue.Column(1)
strWhere = "CompanyID< " & Me.txtWhere
DoCmd.OpenReport "rptTestOpenArgs", acViewPreview, , strWhere, , strOpenArgs
End Sub