print current report

  • Thread starter Thread starter Lisa
  • Start date Start date
L

Lisa

Hi friend,

I have a form that is called testing. It include all of
the information about testing such as Problem ID,
processName,.... I put the print button in this form. but
I want print out report that only include all of the
current form's content.

How sould I do?

thank you

lisa
 
Something like the following in the ONCLICK event...

Private Sub Print_Button_Click()
If (IsNull([ProblemID])) Then
' If no record selected, stop procedure
Exit Sub
End If
DoCmd.OpenReport "Some Report Name", acViewNormal, "",
"[ProblemID]=Forms![TheNameOFYourForm]![ProblemID]"
End Sub



Hope That Helps.

Rick B




Hi friend,

I have a form that is called testing. It include all of
the information about testing such as Problem ID,
processName,.... I put the print button in this form. but
I want print out report that only include all of the
current form's content.

How sould I do?

thank you

lisa
 
Lisa,

You will need to add a Where Condition to the OpenReport method so that the
report shows only the information for the record displayed on your form. For
example, if your field "ProblemID" uniquely identifies the record, you
could use it to determine the where condition as follows:

Dim strCriteria As String

' This works when your ProblemID field is text
strCriteria = "[ProblemID] = " & Chr(34) & Me!ProblemID & Chr(34)
DoCmd.OpenReport "MyReport", acViewNormal, , strCriteria

' This works when your ProblemID field is a number
strCriteria = "[ProblemID] = " & Me!ProblemID
DoCmd.OpenReport "MyReport", acViewNormal, , strCriteria

hth,
 
Back
Top