Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2010
    Posts
    22

    Unanswered: Printing a single record to a report from a form

    Hi All,

    Code:
    Private Sub Preview_Report_Click()
    On Error GoTo Err_Preview_Report_Click
    
    
        Dim stDocName As String
        Dim strWhere As String
        
        stDocName = "Training Record"
        strWhere = "[Employee Name 2] = " & Me![Employee Name 2]
        DoCmd.OpenReport stDocName, acPreview, , strWhere
    
    Exit_Preview_Report_Click:
        Exit Sub
    
    Err_Preview_Report_Click:
        MsgBox Err.Description
        Resume Exit_Preview_Report_Click
        
    End Sub
    Is the code I'm using to print a single record to a report from a form. It works however it raises a message box titled "Enter Parameter Value" and displays the "Employee Name 2" value of the current record.

    My question is how do I change what is displayed in this message box to something more informative like "Please enter Employee's surname" ?

    Thanks,
    Dan

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    The parameter prompt indicates that the name of the field is either incorrect, or not in the report's source. If it's actually a name, the syntax would be slightly different:

    Open a second form to the record
    Paul

  3. #3
    Join Date
    Mar 2010
    Posts
    22
    Thanks for the quick response.

    I tried
    Code:
    DoCmd.OpenForm "SecondFormName", , , "FieldName = '" & Me.ControlName & "'"
    From your site using OpenReport and the appropriate field and control names but got the same result.
    Any other ideas?

    Cheers,
    Dan

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Can you post the db?
    Paul

  5. #5
    Join Date
    Mar 2010
    Posts
    22
    Check your PM

    Thanks,
    Dan

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    That still has the numeric format. This appears to work:

    strWhere = "[Employee Name 2] = '" & Me.Employee_Name_2 & "'"
    Paul

  7. #7
    Join Date
    Mar 2010
    Posts
    22
    Thankyou so much.

    My coding experience is limited but I'm picking it up as I go along.

    Thanks again.
    Dan

  8. #8
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    No problem Dan, happy to help.
    Paul

Posting Permissions

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