Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    44

    Unanswered: Limiting Report Output??

    I currently have a 'main' form where I push a button and another form pops up with more details. These two forms are linked by the primary key so if the main form is displaying information about "A", the popup form will display detailed information about "A".

    Now, I have a button on the popup form that brings up a report preview, however, the problem is it brings up 15 reports; one for each of the primary keys. I need a way so that only one report opens based on the primary key that is currently present on form "A" and the popup form.

    I looked, but I do not believe I saw anything in the code that would let me limit what is coming up. Perhaps I need to run a query and then base the report of the query? Problem that I forsee with that is that the report will be outdated if I change any figures because I have noticed that anything based off of queries seems to have problems.

    Appreiate any insight into this.

  2. #2
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    574
    on the docmd.openreport command, the fourth argument is the where clause:

    docmd.openreport "EquipmentRpt", acViewPreview,, "[EType]='" & primaryKey & "' "

    If you change the form you will probably have to rebuild the report by closing it and opening it again.

  3. #3
    Join Date
    Jan 2004
    Posts
    44
    I get what you mean by fourth argument in the clause, but:

    "[EType]='" & primaryKey & "' "


    means nothing to me. What is the [EType] = ? Though I'm assuming the primarykey would be whatever the primary key is on the table that is being reference rather than some different meaning for primary key.

  4. #4
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    574
    My example showed an equipment report that was restricting the report to only those where the equipment type was that of the primary key on the form. You will have to replace EType with whatever criterion you are looking for; furthermore, my example assumes that etype is a text field. Perhaps I should have used a more generic example:

    docmd.openreport "YourRpt", acViewPreview,, "[YourprimaryKey]='" & primaryKey & "' "

    and if your primaryKey is a number:

    docmd.openreport "YourRpt", acViewPreview,, "[YourprimaryKey]=" & primaryKey

Posting Permissions

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