Results 1 to 4 of 4
  1. #1
    lugnutmonkey is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2013
    Posts
    42

    Question calling multiple reports from single form button

    Hello everybody. I’m very new here and I have a questioninvolving calling one of several reports based on conditions within a form. I’lltry to be as thorough as I can when describing the problem but please feel free to ask for additional information. I've underlined and bolded the important parts.





    My
    goal is to have one button that call all four reports by using some visual basic code to call the proper report based on the combo boxes.

    So my question to you is, Is this possible/realistic?Click image for larger version. 

Name:	Untitled.png 
Views:	15 
Size:	19.1 KB 
ID:	10542
    I have a form that is used to call up reports concerning customer servicepeople and phone calls. Within the form there are two combo boxes and fourbuttons. The combo boxes allow the user to select the year in which a call wasmade/received and the department that received/made the call respectively. Thereare also four buttons used to call up reports, the buttons are "AllDepartment All Years," "Selected Department All Years,""Selected Department All Years," and "Selected DepartmentSelected Year." Each button calls a unique report designed to best displaythe appropriate information. I would like to simplify the interface by writingsome visual basic code that calls the appropriate report based on whether ornot a combo box is selected. For example, If a year isn’t selected but adepartment is the button will call the report, "Selected Department AllYears" I included an image of the form in case any of this was too confusing.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You didn't provide the combo box names or the code you tried, but this should work:

    Code:
    Public Sub YourButtonName()
    
       'AllDepartment All Years
       If IsNull(cboDept) And IsNull(cboFiscalYear) Then
          DoCmd.OpenReport "AllDepartment All Years"
       End If
    
       'Selected Year All Departments
       If IsNull(cboDept) And Not IsNull(cboFiscalYear) Then
          DoCmd.OpenReport "Selected Year All Departments"
       End If
    
       'Selected Department All Years
       If Not IsNull(cboDept) And IsNull(cboFiscalYear) Then
          DoCmd.OpenReport "Selected Department All Years"
       End If
    
       'Selected Department Selected Year
       If Not IsNull(cboDept) And Not IsNull(cboFiscalYear) Then
          DoCmd.OpenReport "Selected DepartmentSelected Year"
       End If
    
    End Sub
    Check/change the names in BLUE.


    If you want to preview the report before printing, add

    , acViewPreview


    to the end of the Docmd lines.


    example:

    DoCmd.OpenReport "AllDepartment All Years", acViewPreview

  3. #3
    lugnutmonkey is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2013
    Posts
    42
    That looks like it will do the trick. Thank you very much.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You're welcome.

    BTW, welcome to the forum

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 11-07-2012, 09:59 AM
  2. Multiple Reports to Single PDF
    By hkimpact in forum Access
    Replies: 1
    Last Post: 06-11-2012, 03:17 PM
  3. single form multiple database
    By sms2720 in forum Programming
    Replies: 7
    Last Post: 12-14-2011, 01:26 PM
  4. Single Form, Multiple Options
    By forrestapi in forum Forms
    Replies: 4
    Last Post: 06-30-2011, 07:09 AM
  5. Replies: 3
    Last Post: 05-23-2011, 01:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums