• Access Reporting (Office 2000)

    • This topic has 2 replies, 2 voices, and was last updated 22 years ago.
    Author
    Topic
    #386821

    Hi,

    I have developed a hardware inventory database that works quite well. It has forms reports and everything. I can print the whole databse but I can’t figure how to write a report for the specific record that I am viewing i.e. I just need to click a button on the form and get it to print that servers details out.

    Can anyone offer any advice on how to do this?

    Viewing 0 reply threads
    Author
    Replies
    • #672665

      You will need a unique identifier for the record. If the table behind the form and report has a primary key on a single field, you can use that.

      In the following, I will assume that you have a numeric primary key ServerID, and that you want to open/print a report rptServers by clicking a command button cmdReport. the On Click event procedure for the button could look like this:

      Private Sub cmdReport_Click()
      ‘ Save record if necessary
      If Me.Dirty Then RunCommand acCmdSaveRecord
      ‘ Open report in print preview mode
      DoCmd.OpenReport “rptServers”, acViewPreview, , “ServerID = ” & Me.ServerID
      End Sub

      Variations:

      • If you want to print directly instead of previewing the report, use acViewNormal instead of acViewPreview, or omit this argument.
      • If your primary key is a text field, replace the Where condition by

        “ServerID = ” & Chr(34) & Me.ServerID & Chr(34)

        Chr(34) is used here to enclose the string value in quotes.
        [/list]Post back if you need more help.

      • #673355

        Hi Hans,

        Thanks for that … it worked perfectly! I can see this is the place to come for Access help ๐Ÿ™‚

    Viewing 0 reply threads
    Reply To: Access Reporting (Office 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: