Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    UK
    Posts
    298
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Access Reporting (Office 2000)

    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?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access Reporting (Office 2000)

    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:
    <UL><LI>If you want to print directly instead of previewing the report, use acViewNormal instead of acViewPreview, or omit this argument.
    <LI>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.

  3. #3
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    UK
    Posts
    298
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: Access Reporting (Office 2000)

    Hi Hans,

    Thanks for that ... it worked perfectly! I can see this is the place to come for Access help :-)

Posting Permissions

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