• Single record on report (Access 2000)

    Author
    Topic
    #365484

    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

    Viewing 2 reply threads
    Author
    Replies
    • #564259

      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.

    • #564315

      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.

    • #564318

      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.

      • #564527

        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?

        • #564530

          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 “

        • #564540

          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

    Viewing 2 reply threads
    Reply To: Single record on report (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: