Prompt User for a Custom Report Name and add it to the report before opening

kengooch

Member
Local time
Today, 13:51
Joined
Feb 29, 2012
Messages
137
I have a button on a form that allows users to create custom reports through the use of multi-select list boxes. Then there are several reporting option buttons on the form. The following code will open the report with the filtered records.
Private Sub Command202_Click() 'This Code Handles the Report based upon the Filter selections DoCmd.OpenReport "rStfCmpltChkLst", acViewReport, , vSetFilters End Sub

I was trying to give the user an option to create a custom report name. I added an unbound text box to the report and named it vRepTitle then added an inputbox request to prompt the user for the report name and assigned that value to vRptTitle, then I tried to pass that title to the unbound text box but it doesn't work. Here is the modified code I tried that doesn't work.
Private Sub Command202_Click() 'This Code Handles the Report based upon the Filter selections vRptTitle = InputBox("Enter the Report Name", "Get Custom Report Name", "Default Custom Report Name") DoCmd.OpenReport "rStfCmpltChkLst", acViewReport, , vSetFilters, vRepTitle = Me.vRptTitle End Sub

Would appreciate corrections
 
One approach is to use the OpenArgs argument and then assign it's value to the Textbox in the Open event of the report.
 
One approach is to use the OpenArgs argument and then assign it's value to the Textbox in the Open event of the report.
I am not familiar with OpenArgs... can you explain further?
 
I am not familiar with OpenArgs... can you explain further?
You could try:
Code:
DoCmd.OpenReport "rStfCmpltChkLst", acViewReport, , vSetFilters, , , Me.vRptTitle
Then, in the Open event of your report,
Code:
Me.vRepTitle = Me.OpenArgs
 
Last edited:
you also need to make sure vRptTitle has a Value (in case Cancel button is clicked on the InputBox).
Code:
Private Sub Command202_Click()
Const sDefaultTitle As String = "Student Complete Checklist"
'This Code Handles the Report based upon the Filter selections

    vRptTitle = InputBox("Enter the Report Name", "Get Custom Report Name", sDefaultTitle)
    If Len(vRptTitle) = 0 Then
        vRptTitle = sDefaultTitle
    End If
    DoCmd.OpenReport "rStfCmpltChkLst", acViewReport, , vSetFilters, vRepTitle = Me.vRptTitle

End Sub
 

Users who are viewing this thread

Back
Top Bottom