Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Jan 2003
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cmd Button - Print Report from Form w/Para.Value.. (Access 2000)

    I want to put a command button on a form that, when clicked, prints the

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

    Re: Cmd Button - Print Report from Form w/Para.Value.. (Access 2000)

    If LastName is unique, you can use it. But if you have some kind of unique ID field (for example an AutoNumber field) that would be even better.

    For a text field such as LastName, the instruction would be:

    <code>DoCmd.OpenReport stDocName , acViewNormal, , "LastName = " & Chr(34) & Me.LastName & Chr(34)</code>

    The Chr(34) correspond to " - they enclose the text value in double quotes (you cannot just put quotes inside a quoted string.)

    For a number field, let's say EmployeeID, it would look like this:

    <code>DoCmd.OpenReport stDocName , acViewNormal, , "EmployeeID = " & Me.EmployeeID</code>

    No extra quotes needed here.

  3. #3
    2 Star Lounger
    Join Date
    Jan 2003
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cmd Button - Print Report from Form w/Para.Value.. (Access 2000)

    Many thanks, Hans...I just tried putting the "LastName" command line in as follows but I still get the "Enter parameter value" dialog. Can you look at this to see what I might have done wrong. Thank you!...Mary

    Private Sub cmdPrintReport_Click()
    On Error GoTo Err_cmdPrintReport_Click

    Dim stDocName As String

    stDocName = "rptFullReport"

    'DoCmd.OpenReport stDocName, acNormal

    DoCmd.OpenReport stDocName, acViewNormal, , "LastName = " & Chr(34) & Me.LastName & Chr(34)
    Exit_cmdPrintReport_Click:
    Exit Sub

    Err_cmdPrintReport_Click:
    MsgBox Err.Description
    Resume Exit_cmdPrintReport_Click
    End Sub

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

    Re: Cmd Button - Print Report from Form w/Para.Value.. (Access 2000)

    Are you sure that LastName (spelled like that) is part of the record source of the form and of the report?

  5. #5
    2 Star Lounger
    Join Date
    Jan 2003
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cmd Button - Print Report from Form w/Para.Value.. (Access 2000)

    Hans, yes, I double check. The record source field name is "LastName" no space. Wonder what else could be the problem?

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

    Re: Cmd Button - Print Report from Form w/Para.Value.. (Access 2000)

    Oh, wait, I forgot something. You wrote 'The report is based on a query where the user has to enter a parameter value (

  7. #7
    2 Star Lounger
    Join Date
    Jan 2003
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cmd Button - Print Report from Form w/Para.Value.. (Access 2000)

    Hans, you're right--that was it! However, because I needed that query w/parameter value for running a Switchboard report, I just copied the original query and report and then used the copies for the form's command button to print the report for current record. Thank you, thank you, thank you! As always, I really appreciate your help. ...Mary

Posting Permissions

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