Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2010

    Unanswered: Generating a Report

    Ok So I have set up a date selector to generate a productivity report for all employees for a range of dates, this part works great. Now I want to add another selector field for a report I named Employee Report which will allow me to select a start date, end date (these are done) and then allow me to select an employee from the db with a drop down and run a report just for that user.

    The report is already mapped out in design view and my code already has the date selector up so I just need to know how to set up the dropdown that will allow me to select an employee first.

    Here is the event code for what I already have

    Option Compare Database
    Option Explicit
    Private StartDate As Variant
    Private EndDate As Variant
    Private shadeNextRow As Boolean
    Const shadedColor = 15726583
    Const normalColor = 16777215
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
      On Error GoTo Detail_Format_Error
      If shadeNextRow = True Then
        Me.Section(acDetail).BackColor = shadedColor
        Me.Section(acDetail).BackColor = normalColor
      End If
      shadeNextRow = Not shadeNextRow
      Exit Sub
      MsgBox "Error " & Err.Number & ": " & Err.Description
      Resume Detail_Format_Exit
    End Sub
    Private Sub Report_Open(Cancel As Integer)
    StartDate = InputDate("Select Start Date")
    EndDate = InputDate("Select End Date")
    If IsDate(StartDate) And IsDate(EndDate) Then
        Me.Filter = "Date Between #" & StartDate & "# And #" & _
            EndDate & "#"
        Me.FilterOn = True
    End If
    End Sub
    Any help is much appreciated

  2. #2
    Join Date
    Feb 2004
    Chicago, IL
    I would suggest using a form to get the start, end and employee. The easiest way for a user to enter an employee is by selecting the employee from a list of employees. The best ways to do that is to use a combo box or a list box. The only way I know of to use those two controls like that is with a form.

    Create a form with three fields on it. Start Date, End Date and Employee combo box. Then add a Close button and a Print button. In the the Print command's On Click event you will build you filter the same way and call the DoCmd.Open acReport, ReportName. The fifth or so parameter is the Where parameter or the filter. Build you filter string and then pass it using the DoCmd.Open method.

    I think this way the report will be more flexible. If the user selects an employee then the report shows for that employee. If the user does NOT select an employee then the report can show all of the employees for that range.

  3. #3
    Join Date
    Sep 2010
    I basically have this already I have the calendar pop up and you click start date then it comes up again when the day is selected then it runs the report for all employees in those dates. I would like to simply add a employee box after the end date box is clicked.

    I am new to access so I am confused as to where or how to code it. Is it something I can just add to the event code mentioned in the first post or ???

Posting Permissions

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