Report from the Form that the user is on.

G

Guest

I would like to have a report that will show the data that the user is
looking at on a form. With the Code bellow it only opens but it does not show
any data. The Link [Permit_Ap_Key_ID] is a number.

Private Sub Command21_Click()
On Error GoTo Err_Command21_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Permit_Rpt"

stLinkCriteria = [Permit_Ap_Key_ID] = " & Me![Permit_Ap_Key_ID] & "
DoCmd.Close
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria

Exit_Command21_Click:
Exit Sub

Err_Command21_Click:
MsgBox Err.Description
Resume Exit_Command21_Click

End Sub
 
M

Marshall Barton

KAnoe said:
I would like to have a report that will show the data that the user is
looking at on a form. With the Code bellow it only opens but it does not show
any data. The Link [Permit_Ap_Key_ID] is a number.

Private Sub Command21_Click()
On Error GoTo Err_Command21_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Permit_Rpt"

stLinkCriteria = [Permit_Ap_Key_ID] = " & Me![Permit_Ap_Key_ID] & "
DoCmd.Close
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria


You have the quotes in the wrong place:

stLinkCriteria ="[Permit_Ap_Key_ID] = " _
& Me![Permit_Ap_Key_ID]

Also, make sure you have saved any changes to the current
record before trying to run the report:

If Me.Dirty Then Me.Dirty = False

Even if that makes it work, for my own sanity, I would Close
the form after after I opened the report.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top