If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
criteria
I have a report and a subreport run from queries which each require the
input of a beginning date and an ending date. I would like to be requested to input the criteria once instead of twice. Thanks |
#2
|
|||
|
|||
criteria
On Tue, 24 Feb 2009 13:34:01 -0800, Christina wrote:
I have a report and a subreport run from queries which each require the input of a beginning date and an ending date. I would like to be requested to input the criteria once instead of twice. Thanks You will need a form for this. Create a form. Add 2 unbound text controls. Set their format property to a valid date format. Name one control "StartDate'. Name the other control "EndDate". Add a command button to the form. Code it's click event: DoCmd.OpenReport "ReportName", acViewPreview Me.Visible = False Name this form "ParamForm". As criteria for the main report query, and also for the sub-report query, enter, on the Date field's criteria line: Between Forms!ParamForm!StartDate and Forms!ParamForm!EndDate Code the Main Report's Close event: DoCmd.Close acForm, "ParamForm" Then when you are ready to run the report, open the form. Enter the starting and ending dates wanted. Click the command button. The report and it's sub report will run. When the report closes, it will also close the form. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#3
|
|||
|
|||
criteria
Thanks you. I am not sure how to add the code to the click event or code
the main report close event. Please for detail instructions. Thanks "fredg" wrote: On Tue, 24 Feb 2009 13:34:01 -0800, Christina wrote: I have a report and a subreport run from queries which each require the input of a beginning date and an ending date. I would like to be requested to input the criteria once instead of twice. Thanks You will need a form for this. Create a form. Add 2 unbound text controls. Set their format property to a valid date format. Name one control "StartDate'. Name the other control "EndDate". Add a command button to the form. Code it's click event: DoCmd.OpenReport "ReportName", acViewPreview Me.Visible = False Name this form "ParamForm". As criteria for the main report query, and also for the sub-report query, enter, on the Date field's criteria line: Between Forms!ParamForm!StartDate and Forms!ParamForm!EndDate Code the Main Report's Close event: DoCmd.Close acForm, "ParamForm" Then when you are ready to run the report, open the form. Enter the starting and ending dates wanted. Click the command button. The report and it's sub report will run. When the report closes, it will also close the form. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#4
|
|||
|
|||
criteria
On Tue, 24 Feb 2009 19:51:01 -0800, Christina wrote:
Thanks you. I am not sure how to add the code to the click event or code the main report close event. Please for detail instructions. Thanks "fredg" wrote: On Tue, 24 Feb 2009 13:34:01 -0800, Christina wrote: I have a report and a subreport run from queries which each require the input of a beginning date and an ending date. I would like to be requested to input the criteria once instead of twice. Thanks You will need a form for this. Create a form. Add 2 unbound text controls. Set their format property to a valid date format. Name one control "StartDate'. Name the other control "EndDate". Add a command button to the form. Code it's click event: DoCmd.OpenReport "ReportName", acViewPreview Me.Visible = False Name this form "ParamForm". As criteria for the main report query, and also for the sub-report query, enter, on the Date field's criteria line: Between Forms!ParamForm!StartDate and Forms!ParamForm!EndDate Code the Main Report's Close event: DoCmd.Close acForm, "ParamForm" Then when you are ready to run the report, open the form. Enter the starting and ending dates wanted. Click the command button. The report and it's sub report will run. When the report closes, it will also close the form. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail For the Form, select the Command Button. Display the button's property sheet. Click on the Event tab. Click on the event line you wish to code, i.e. the Click event. Write [Event Procedure] on that line. Then click on the little button with the 3 dots that appears on that line. When the code window opens, the cursor will be flashing between 2 already existing lines of code. Between those lines write your code for the command button. DoCmd.OpenReport "ReportName", acViewPreview Me.Visible = False For the Report, display the Report's property sheet. Click on the Close evnet line and follow the same instructions as for the Form Command button. Write the code: DoCmd.Close acForm, "ParamForm" -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#5
|
|||
|
|||
criteria
Small question. WHen I am create the command button, do I follow all the
instructions and link the report to the button? Otherwise I need to know what to do when I create the button so that I can put the code. Hope you understand my question. Thanks "fredg" wrote: On Tue, 24 Feb 2009 19:51:01 -0800, Christina wrote: Thanks you. I am not sure how to add the code to the click event or code the main report close event. Please for detail instructions. Thanks "fredg" wrote: On Tue, 24 Feb 2009 13:34:01 -0800, Christina wrote: I have a report and a subreport run from queries which each require the input of a beginning date and an ending date. I would like to be requested to input the criteria once instead of twice. Thanks You will need a form for this. Create a form. Add 2 unbound text controls. Set their format property to a valid date format. Name one control "StartDate'. Name the other control "EndDate". Add a command button to the form. Code it's click event: DoCmd.OpenReport "ReportName", acViewPreview Me.Visible = False Name this form "ParamForm". As criteria for the main report query, and also for the sub-report query, enter, on the Date field's criteria line: Between Forms!ParamForm!StartDate and Forms!ParamForm!EndDate Code the Main Report's Close event: DoCmd.Close acForm, "ParamForm" Then when you are ready to run the report, open the form. Enter the starting and ending dates wanted. Click the command button. The report and it's sub report will run. When the report closes, it will also close the form. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail For the Form, select the Command Button. Display the button's property sheet. Click on the Event tab. Click on the event line you wish to code, i.e. the Click event. Write [Event Procedure] on that line. Then click on the little button with the 3 dots that appears on that line. When the code window opens, the cursor will be flashing between 2 already existing lines of code. Between those lines write your code for the command button. DoCmd.OpenReport "ReportName", acViewPreview Me.Visible = False For the Report, display the Report's property sheet. Click on the Close evnet line and follow the same instructions as for the Form Command button. Write the code: DoCmd.Close acForm, "ParamForm" -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#6
|
|||
|
|||
criteria
Hi, The report does not return any data. I created the form with the two
text Boxes as instructed. I added a command button with this code in the click event. Private Sub Command21_Click() DoCmd.OpenReport "Reconciliation", acViewPreview Me.Visible = False There were some other code in there before the End Sub. Should I delete that? I tried it both ways anyhow, and it did not run. Don't know what I am doing wrong. Christina" wrote: Small question. WHen I am create the command button, do I follow all the instructions and link the report to the button? Otherwise I need to know what to do when I create the button so that I can put the code. Hope you understand my question. Thanks "fredg" wrote: On Tue, 24 Feb 2009 19:51:01 -0800, Christina wrote: Thanks you. I am not sure how to add the code to the click event or code the main report close event. Please for detail instructions. Thanks "fredg" wrote: On Tue, 24 Feb 2009 13:34:01 -0800, Christina wrote: I have a report and a subreport run from queries which each require the input of a beginning date and an ending date. I would like to be requested to input the criteria once instead of twice. Thanks You will need a form for this. Create a form. Add 2 unbound text controls. Set their format property to a valid date format. Name one control "StartDate'. Name the other control "EndDate". Add a command button to the form. Code it's click event: DoCmd.OpenReport "ReportName", acViewPreview Me.Visible = False Name this form "ParamForm". As criteria for the main report query, and also for the sub-report query, enter, on the Date field's criteria line: Between Forms!ParamForm!StartDate and Forms!ParamForm!EndDate Code the Main Report's Close event: DoCmd.Close acForm, "ParamForm" Then when you are ready to run the report, open the form. Enter the starting and ending dates wanted. Click the command button. The report and it's sub report will run. When the report closes, it will also close the form. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail For the Form, select the Command Button. Display the button's property sheet. Click on the Event tab. Click on the event line you wish to code, i.e. the Click event. Write [Event Procedure] on that line. Then click on the little button with the 3 dots that appears on that line. When the code window opens, the cursor will be flashing between 2 already existing lines of code. Between those lines write your code for the command button. DoCmd.OpenReport "ReportName", acViewPreview Me.Visible = False For the Report, display the Report's property sheet. Click on the Close evnet line and follow the same instructions as for the Form Command button. Write the code: DoCmd.Close acForm, "ParamForm" -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#7
|
|||
|
|||
criteria
On Wed, 25 Feb 2009 14:32:01 -0800, Christina wrote:
Hi, The report does not return any data. I created the form with the two text Boxes as instructed. I added a command button with this code in the click event. Private Sub Command21_Click() DoCmd.OpenReport "Reconciliation", acViewPreview Me.Visible = False There were some other code in there before the End Sub. Should I delete that? I tried it both ways anyhow, and it did not run. Don't know what I am doing wrong. Christina" wrote: Small question. WHen I am create the command button, do I follow all the instructions and link the report to the button? Otherwise I need to know what to do when I create the button so that I can put the code. Hope you understand my question. Thanks *** snipped *** I don't know what you are doing wrong either, as I am here and you are there. :-( Don't use the Wizard when you know the code you wish to use. So yes, delete any other code in that command button's click event. The complete code (in that event) should look like this: Private Sub Command12_Click() DoCmd.OpenReport "Reconciliation", acViewPreview Me.Visible = False End Sub The same goes for the Report Close event. Don't use the Command Button wizard. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#8
|
|||
|
|||
criteria
Thanks again. Problem, the only way I k now to create a command button is
with the wizard . Can you please walk me through. "fredg" wrote: On Wed, 25 Feb 2009 14:32:01 -0800, Christina wrote: Hi, The report does not return any data. I created the form with the two text Boxes as instructed. I added a command button with this code in the click event. Private Sub Command21_Click() DoCmd.OpenReport "Reconciliation", acViewPreview Me.Visible = False There were some other code in there before the End Sub. Should I delete that? I tried it both ways anyhow, and it did not run. Don't know what I am doing wrong. Christina" wrote: Small question. WHen I am create the command button, do I follow all the instructions and link the report to the button? Otherwise I need to know what to do when I create the button so that I can put the code. Hope you understand my question. Thanks *** snipped *** I don't know what you are doing wrong either, as I am here and you are there. :-( Don't use the Wizard when you know the code you wish to use. So yes, delete any other code in that command button's click event. The complete code (in that event) should look like this: Private Sub Command12_Click() DoCmd.OpenReport "Reconciliation", acViewPreview Me.Visible = False End Sub The same goes for the Report Close event. Don't use the Command Button wizard. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#9
|
|||
|
|||
criteria
Hi, I got to create the botton without the wizard. When I run the report it
gives me Compile error Invalid Outside procedure. Thanks "Christina" wrote: Hi, The report does not return any data. I created the form with the two text Boxes as instructed. I added a command button with this code in the click event. Private Sub Command21_Click() DoCmd.OpenReport "Reconciliation", acViewPreview Me.Visible = False There were some other code in there before the End Sub. Should I delete that? I tried it both ways anyhow, and it did not run. Don't know what I am doing wrong. Christina" wrote: Small question. WHen I am create the command button, do I follow all the instructions and link the report to the button? Otherwise I need to know what to do when I create the button so that I can put the code. Hope you understand my question. Thanks "fredg" wrote: On Tue, 24 Feb 2009 19:51:01 -0800, Christina wrote: Thanks you. I am not sure how to add the code to the click event or code the main report close event. Please for detail instructions. Thanks "fredg" wrote: On Tue, 24 Feb 2009 13:34:01 -0800, Christina wrote: I have a report and a subreport run from queries which each require the input of a beginning date and an ending date. I would like to be requested to input the criteria once instead of twice. Thanks You will need a form for this. Create a form. Add 2 unbound text controls. Set their format property to a valid date format. Name one control "StartDate'. Name the other control "EndDate". Add a command button to the form. Code it's click event: DoCmd.OpenReport "ReportName", acViewPreview Me.Visible = False Name this form "ParamForm". As criteria for the main report query, and also for the sub-report query, enter, on the Date field's criteria line: Between Forms!ParamForm!StartDate and Forms!ParamForm!EndDate Code the Main Report's Close event: DoCmd.Close acForm, "ParamForm" Then when you are ready to run the report, open the form. Enter the starting and ending dates wanted. Click the command button. The report and it's sub report will run. When the report closes, it will also close the form. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail For the Form, select the Command Button. Display the button's property sheet. Click on the Event tab. Click on the event line you wish to code, i.e. the Click event. Write [Event Procedure] on that line. Then click on the little button with the 3 dots that appears on that line. When the code window opens, the cursor will be flashing between 2 already existing lines of code. Between those lines write your code for the command button. DoCmd.OpenReport "ReportName", acViewPreview Me.Visible = False For the Report, display the Report's property sheet. Click on the Close evnet line and follow the same instructions as for the Form Command button. Write the code: DoCmd.Close acForm, "ParamForm" -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#10
|
|||
|
|||
criteria
On Thu, 26 Feb 2009 08:56:07 -0800, Christina wrote:
Thanks again. Problem, the only way I k now to create a command button is with the wizard . Can you please walk me through. "fredg" wrote: On Wed, 25 Feb 2009 14:32:01 -0800, Christina wrote: Hi, The report does not return any data. I created the form with the two text Boxes as instructed. I added a command button with this code in the click event. Private Sub Command21_Click() DoCmd.OpenReport "Reconciliation", acViewPreview Me.Visible = False There were some other code in there before the End Sub. Should I delete that? I tried it both ways anyhow, and it did not run. Don't know what I am doing wrong. Christina" wrote: Small question. WHen I am create the command button, do I follow all the instructions and link the report to the button? Otherwise I need to know what to do when I create the button so that I can put the code. Hope you understand my question. Thanks *** snipped *** I don't know what you are doing wrong either, as I am here and you are there. :-( Don't use the Wizard when you know the code you wish to use. So yes, delete any other code in that command button's click event. The complete code (in that event) should look like this: Private Sub Command12_Click() DoCmd.OpenReport "Reconciliation", acViewPreview Me.Visible = False End Sub The same goes for the Report Close event. Don't use the Command Button wizard. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail In Design View, click on the Toolbox tool button. If the Wizard button is down (the button with the wand and falling stars), click on it to raise it. Now add your command button. Since the wizard is not turned on, you can now simply add code to the button's click event using the method I gave you previously. Don't forget to use the Command button's Caption property to write whatever button caption you wish. If you need to use the wizard again in the future, simply open the toolbox and depress the wizard (the wand with the stars) button. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
|
Thread Tools | |
Display Modes | |
|
|