Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Oct 2001
    Location
    Indiana, USA
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Single record on report (Access 2000)

    I need to print a report for individual records. Each record contains a change request that will be printed on a standard form. I have the report designed and can print all records from a query or table, but I need to print the recorn currently displayed on a form. Does anyone have ideas that might help?
    Thanks, Mark

  2. #2
    Star Lounger
    Join Date
    Dec 2001
    Location
    Fredensborg, Denmark
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Single record on report (Access 2000)

    Open your form in design mode and use the toolbox to put a button on the form. When the guide asks you for the action to perform choose report.
    When the button has been created show the program code and correct the DoCmd.OpenReport stmt to something like this:

    DoCmd.OpenReport stDocName, acPreview, , "[YourID]=forms!frmKunde!YourID "

    where YourID is the name of the primary key of the record displayed on the form.

    If you have done updates on the form, make sure the record is saved first.

  3. #3
    New Lounger
    Join Date
    Nov 2001
    Location
    Twickenham, UK
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Single record on report (Access 2000)

    If you're new to Access and prefer to keep away from the code, the easiest option is to base your report on a select query (if it isn't already) and in the design view of the query in the criteria for your unique id field add
    Forms![Your_Form_Name]![Unique_ID_Field]

    Then, as suggested previously, use the wizard to create an Open Report button on your form.

    This way the report only shows the record currently visible on your form without you needing to amend any code.

  4. #4
    Star Lounger
    Join Date
    Dec 2001
    Location
    Fredensborg, Denmark
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Single record on report (Access 2000)

    Sorry Mark,

    I forgot to tell you that the name frmKunde should be replaced by the name of your form.
    If you always want your query to return one record only, then use Chris' suggestion.
    If you want the ability to print all records using the same query as well, then use my suggestion.

  5. #5
    New Lounger
    Join Date
    Oct 2001
    Location
    Indiana, USA
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Single record on report (Access 2000)

    Thanks for the help. I am trying both your suggestion and Chris' as well. I am getting a syntax error when I try the code (missing operator).
    I have DoCmd.OpenReport stDocName, acPreview, , "[ECR_Number]=forms!ECR Report!ECR_Number "

    ECR_Number is the primary key on my form & ECR Report is my report name.

    Do you see what I am doing wrong?

  6. #6
    Star Lounger
    Join Date
    Dec 2001
    Location
    Fredensborg, Denmark
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Single record on report (Access 2000)

    The name of your report is hopefully in stDocname. Look at the code preceeding the DoCmd.

    Replace ECR Report by the name of your form inclosed in [] if it contains spaces.
    If your form is name ECR Form the stmt should look like this:

    DoCmd.OpenReport stDocName, acPreview, , "[ECR_Number]=forms![ECR Form]!ECR_Number "

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Single record on report (Access 2000)

    The WhereCondition is a string so you want to pass it the condition to evaluate, not the reference to the form. Change it to this:

    DoCmd.OpenReport stDocName, acPreview, , "[ECR_Number]=" & forms!ECR Report!ECR_Number
    Charlotte

Posting Permissions

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