Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2012

    Unanswered: Use the same form ( Form!yearselection ! CboYear ) as criteria for several reports

    I have a form that I select the year by a combo box as criteria for a report. I want to use this for two more reports. On the form is a cmd button how can I use the same button.

    Thanks Bob

  2. #2
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    Quote Originally Posted by Robert(Bob) View Post

    ...On the form is a cmd button how can I use the same button...
    For run multiple Reports, for the same year, at the same time? If so, you simply need to place the commands in the single OnClick event:

    Private Sub cmdRunReports_Click()
      DoCmd.OpenReport "Report1", acViewNormal
      DoCmd.OpenReport "Report2", acViewNormal
      DoCmd.OpenReport "Report3", acViewNormal
    End Sub

    If you mean something else, you need to give a much more in depth explanation.

    Linq ;0)>
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    better yet specify the year as a parameter of the open report macro.
    its the 4th parameter

    say the relevant column in your data is called fYear
    then its going to be something like:-
    DoCmd.OpenReport "Reportx", acViewNormal,,'fYear = ' & Form!yearselection!CboYear
    its up to you to wrap the code with relevent error handlers (in case Form!yearselection!CboYear isn't in the current scope or isn't loaded, or isn't a valid value.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Jan 2009
    Kerala, India
    Click image for larger version. 

Name:	Report Parameter Form.jpg 
Views:	4 
Size:	37.1 KB 
ID:	17098

    You may create a Report Parameter Screen with a Group Control (with three Radio Buttons) and a Command Button, like the attached image. Before running the Report by clicking on the command button select the Report option on the Group control.

    The following Code will check which Report to open after checking the option selected on the group control:
    Private Sub cmdPreview_Click()
    Dim x As Integer, strReport As String
    DoCmd.RunCommand acCmdSaveRecord
    On Error Resume Next
    x = Me![frDN]
    Select Case x
       Case 1
          strReport = "A_Instalment_DueCases"
       Case 2
          strReport = "A_DNYes_0Pyts"
       Case 3
          strReport = "A_DN_NotRaised"
    End Select
    If x Then DoCmd.OpenReport strReport, acViewPreview
    End Sub (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts