Results 1 to 2 of 2
  1. #1
    stephenaa5 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    72

    filter by form for report

    I have two tables, Customers and Jobs. There is a JobQuery that combines both for viewing on a split form DispatchForm.



    DispatchForm shows the currently highlighted job in great detail at the top of the screen, while having the datasheet view below the rail show various pieces of data upon which a user might filter information. The filtering works fine, now we need output.

    I would like to have those filters that are selected be applied to a report, so they can get output. Currently, we go to a report filtering screen, which is not pretty.

    I have tried to create a button that essentially has the following procedure:

    Private Sub cmdOpenReport_Click()
    DoCmd.OpenReport "rptDISPATCH", acViewPreview, , Me.Filter
    End Sub

    What happens is that the report launches, but I get an error that the query is looking for whatever data the user has selected as a filter. Clearly I'm conceptually wrong.

    Thoughts?

    Thank you,

    Stephen.

  2. #2
    Datagopherdan is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Dec 2008
    Posts
    220
    Hi Steven,

    I'm not sure of what field you are trying to filter on but here's a basic sample of how to apply a filter to a report in VBA. You would just create an unbound text box where the user would enter the criteria or base it off an existing field in a form.

    Code:
        strMyField = "[ml_ID]= " & Me.txtMyField 
    DoCmd.OpenReport "YourReport", acViewPreview, , strMyField

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

Similar Threads

  1. Replies: 2
    Last Post: 11-25-2013, 10:56 AM
  2. Filter form by column
    By smikkelsen in forum Forms
    Replies: 10
    Last Post: 04-27-2010, 10:46 PM
  3. Checkbox filter on a form
    By aletrindade in forum Access
    Replies: 1
    Last Post: 12-02-2009, 06:22 AM
  4. How to Filter Report
    By mikel in forum Reports
    Replies: 2
    Last Post: 08-28-2009, 10:11 AM
  5. Replies: 19
    Last Post: 05-12-2009, 02:59 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