Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2006
    Posts
    8

    Lightbulb Unanswered: Report pulling from data displayed on particular record on the form

    I have create this project for my work, but I am hindered by the fact that I can not use any VB code at all. It must strictly be done using queries, macros, etc...


    I have a form that displays each record. I want to have a button that displays a report from that form for that particular record. So each record you go to will pull a different report for that particular record. My database is one were someone logs errors that they found for an associate. The supervisor will then go into the database and will go into the database to view all new records that haven't been resolved and it a particular check box is marked yes, then they will need to print out a report that is basically a summary of the mistake for the associate to sign. How can I get the report to pull the info from the current record they are viewing and exclude the others? I really appreciate any help you can give.

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    The OpenReport action has a wherecondition argument.
    Paul

  3. #3
    Join Date
    Jan 2006
    Posts
    8

    ...

    what would i use as the condition?
    I am not sure how I would say "open the report but show the current record and no other"
    say I am using an account number to uniquely identify each record, what would be the best condition?

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    On your form you should have a unique identifier (i.e. Primary Key) which uniquely identifies that record (say the field is called PKey). The button to open your report would then look like this:

    If the Primary Key is an integer value:
    DoCmd.OpenReport "MyReport", , , "[PKey] = " & Forms!MyFormName!PKey & "", acViewPreview

    If the Primary Key is a string value:
    DoCmd.OpenReport "MyReport", , , "[PKey] = '" & Forms!MyFormName!PKey & "'", acViewPreview
    Note: the "'" is " ' " (to show you what symbols are used)

    If you want to minimize the form first before opening the report, put in
    docmd.minimize
    before you issue the docmd.openreport.... command
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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