set data of text box

Dovidg

New member
Local time
Today, 00:05
Joined
Nov 20, 2012
Messages
5
I want to click on button on form and based on which button set text in text box.
If I click on button Jon = Jon will be in text box
 
This is the Report forum but you mention only Form in your question. Can you please share more specific details or requirements?
 
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
 
Note that while it is relatively easy to do what you want, reports tend to make command buttons more difficult due to timing of multiple events that fire repeatedly for report detail and header and footer sections. In forms, this is a trivial question. In theory you can do it in a report, but the question becomes "when does it take effect?" OR "when do you WANT it to take effect?" That, among other things, is certainly implied in DHookum's question.
 
Your post crossed mine, apparently.

You have half the battle if you can make the OpenArgs hold the right value. The other half is that in the Report_Open event code, you can do something simple like

Code:
Me.TheTextBox = Me.OpenArgs
 
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
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.
 
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

1737500832841.png
 
code for button on form
on click
Dim strOpenArgs As String
strOpenArgs = “jon”
DoCmd.OpenReport "RptRList", acViewPreview, , , , OpenArgs = "strOpenArgs"

Textbox in report
control source =[OpenArgs]

did not work, what am I doing wrong
thank you very much
 
Your code doesn’t match mine. I didn’t have an “=“ or "strOpenArgs" (in quotes) in my OpenReport code.
 
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
perfect, I was lazy
how do you do this chart of open args value.
where do you put it
thank you again, very helpful
dg
 
Your code doesn’t match mine. I didn’t have an “=“ or "strOpenArgs" (in quotes) in my OpenReport code.
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.
thank you again
 

Users who are viewing this thread

Back
Top Bottom